In Visual Basic, is there a performance difference when using the IIf function instead of the If statement?
In Visual Basic, is there a performance difference when using the IIf function instead
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
VB has the following
Ifstatement which the question refers to, I think:The first is basically C#’s ternary conditional operator and the second is its coalesce operator (return
resultunless it’sNothing, in which case return'Alternative').Ifhas thus replacedIIfand the latter is obsolete.Like in C#, VB’s conditional
Ifoperator short-circuits, so you can now safely write the following, which is not possible using theIIffunction: