According to the Best Practices section of the MSDN documentation for the System.Enum class:
Do not specify the value of an enumeration just to reflect the state of the enumeration itself. For example, do not define an enumerated constant that simply marks the end of the enumeration. If you need to determine the last value of an enumeration, check this value explicitly. In addition, you can perform a range check for the first and last enumerated constant if all values ​​within the range are valid.
If I understand correctly, we should not declare the listing as follows.
public enum DrawOrder
{
VeryBottom = 0,
Bottom = 1,
Middle = 2,
Top = 3,
Lowest = VeryBottom,
Highest = Top,
}
Why is this considered bad practice?
source
share