#174 – Multiple Case Statements in switch Statement Can Share Code
December 8, 2010 Leave a comment
In a C# switch statement, you can group several case statements with the same block of code. If the switch expression has a value matching any of the listed case statements, the corresponding code will be executed.
switch (movieRating) // 1-5
{
case 1:
case 2:
Console.WriteLine("Not worth seeing");
break;
case 3:
case 4:
Console.WriteLine("Consider seeing it");
break;
case 5:
Console.WriteLine("Absolutely must see it");
break;
}