Skip to content

Gendarme.Rules.Design.EnumsShouldDefineAZeroValueRule(2.10)

Sebastien Pouliot edited this page Feb 9, 2011 · 3 revisions

EnumsShouldDefineAZeroValueRule

Assembly: Gendarme.Rules.Design
Version: 2.10

Description

This rule ensures that every non-flags enumeration contains a 0 value. This is important because if a field is not explicitly initialized .NET will zero-initialize it and, if the enum has no zero value, then it will be initialized to an invalid value.

Examples

Bad example:

enum Position {
    First = 1,
    Second
}

Good example:

enum Position {
    First,
    Second
}
Clone this wiki locally