search
Login

Categories


C Books Guide and List
C++ Books Guide and List
Best Java Books

3.8k questions

4k answers

117 comments

10.7k users

0 votes
23 views
asked Guru 27.1k points 31 50 97

1 Answer

0 votes

 

 
The switch statement is a selection control statement that is used to handle multiple choices and transfer control to the case statements within its body. The following code snippet shows an example of the use of the switch statement in C#: 
switch(choice)
{
 case 1:
 console.WriteLine("First"); 
 break;
 case 2:
 console.WriteLine("Second");
 break;
 default:
 console.WriteLine("Wrong choice");
 break;
}
 
In switch statements, the break statement is used at the end of a case statement. The break statement is mandatory in C# and it avoids the fall through of one case statement to another.
 
answered Expert 13.2k points 27 40 59

Related questions

0 votes
1 answer 39 views
39 views
asked john Guru 27.1k points 31 50 97
0 votes
1 answer 68 views
68 views
asked john Guru 27.1k points 31 50 97
0 votes
1 answer 1.2K views
1 vote
1 answer 54 views
0 votes
1 answer 1.4K views
1.4K views
asked john Guru 27.1k points 31 50 97
...