The requested page is not available for the requested platform. You are viewing the content for Default platform.

Expand Ternary Expression

Converts a ternary expression into an if/else block.

Availability

Available from the context menus or via shortcuts:

  • when the caret is on an expression containing a ternary operator ("? :" operator in C# and C++, IIf operator in Visual Basic).

Notes

Example

b = a ? 10 : 20;
b = If(a, 10, 20)

Result:

if (a)
    b = 10;
else
    b = 20;
If a Then
    b = 10
Else
    b = 20
End If

Animation

CSharpExpandTernaryExpression

See Also