TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
C# Coding Standard
Search

Rule:  6@105Checked automatically with code checker

Synopsis:Ensure switch statements are exhaustive
Language:C#
Severity Level:2
Category:Control flow


Description:

When a switch statement is used on a variable of an enumeration type, all values of that enum should be covered by the switch statement; either by explicitly listing all values, or by using a default label.

If no action is required for the default case, a comment such as 'no action' is recommended. If the default case should be unreachable, an assertion to this effect is recommended.

Furthermore, if a default label is used, it should always be used on the last section. This ensures the default label is easy to locate. This requirement applies to all switch switch statements, including those that are used on variables of non-enum types.