QuestionQ85

Control Flow

Which option shows the correct syntax for using the VB.NET "If" operator?

Explanation

In VB.NET, the If operator (as opposed to the If...Then...Else statement) is written as a function-style call: If(condition, valueIfTrue, valueIfFalse). It evaluates the condition and returns valueIfTrue if the condition is true, or valueIfFalse otherwise, all within a single expression using parentheses and comma-separated arguments, as documented in Microsoft's VB.NET language reference for the If Operator.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!