What is the use of 'else' statement in C# programming language?

 Posted by Goud.Kv on 9/1/2014 | Category: C# Interview questions | Views: 1444 | Points: 40
Answer:

else is a selection statement used with if statement to execute the alternate conditions of if statement.

Example,
int x = 10, y = 5;

if (x == y)
{
Console.WriteLine("Both x and y are equal....");
}
else
{
Console.WriteLine("Both x and y are not equal....");
}


Asked In: Spotted While Learning | Alert Moderator 

Comments or Responses

Login to post response