I like to use switch statement rather than using continuous if statement or atleast if I have to use more than 3 if statement. The syntax and example can be a good reference.
SYNTAX:
Console.WriteLine( "Case 1" ); |
Console.WriteLine( "Case 2" ); |
Console.WriteLine( "Default case" ); |
Example:
string strCityName = "Madras" ; |
Response.Write(strCityName.ToString() + " : Capital of Tamil Nadu" ); |
Response.Write(strCityName.ToString() + " : Capital of West Bengal" ); |
Response.Write(strCityName.ToString() + " : Capital of Maharashtra" ); |
Response.Write(strCityName.ToString() + " : City not in the list" ); |