What do you mean by switch and case statements in C# programming language?

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

These both are the selection statements used to together to perform switch operations. In other words, switch is used to execute particular section (case) of the statement.

Example,
string Name = "Krishna";

switch (Name)
{
case "Krishna": // This case will be executed...
...............;
break;
case "Vamshi":
...............;
break;
default:
...............;
break;
}


For every case, break should be used to terminate the execution and let it go to the next case.


Asked In: Spotted While Learning | Alert Moderator 

Comments or Responses

Login to post response