C# Compared—If Then

Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio


Jump to: navigation, search
CSharp-Online.NET:Articles
C# Articles

C# Compared to Other Languages

© 2005 C. Gunnerson, et al.

If Then

In C#, there is no Then statement; after the condition comes the statement or statement block that should be executed if the condition is true, and after that statement or block there is an optional else statement.

The following VB code

If size < 60 Then
   value = 50
Else
   value = 55
   order = 12
End If

can be rewritten as

if (size < 60)
   value = 50;
else
{
   value = 55;
   order = 12;
}

There is no ElseIf statement in C#.


Previous_Page_.gif Next_Page_.gif


Personal tools