Initialize Conditionally
In This Article
Moves a variable initialization to the else block.
#Availability
Available from the context menu or via shortcuts:
- when the cursor is on a variable initialization, provided that the following if block contains an assignment statement for this variable.
#Examples
int i = 0;
if (a)
i = 1;
Dim i As Integer = 0
If a Then
i = 1
End If
Result:
int i;
if (a)
i = 1;
else
i = 0;
Dim i As Integer
If a Then
i = 1
Else
i = 0
End If