Switch can act upon enum values. An enum switch sometimes results in clearer code. It sometimes is faster. This code pattern is often effective. It is used in many real-world programs, not just website examples.

Example. Enums are useful in your program if it has to use magic constants. For the switch statement, look at the IsImportant method defined at the bottom of this example. It uses five explicit cases and a default case.

This program defines a custom method that contains a switch, which tests the parameter that is an enum of type Priority. It returns true if the Priority value is Important or Critical. Otherwise it returns false.

Internals. How is the enum switch compiled? The above C# code is compiled into a special .NET Framework instruction called a jump table. The jump table uses the IL instruction switch. It defines one jump "point" to each case.