#174 – Multiple Case Statements in switch Statement Can Share Code

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");
                case 3:
                case 4:
                    Console.WriteLine("Consider seeing it");
                case 5:
                    Console.WriteLine("Absolutely must see it");

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: