Each enum member has an underlying integral value. - CSharp Custom Type

CSharp examples for Custom Type:Enum

Introduction

By default, underlying values are of type int.

The constants 0, 1, 2... are automatically assigned, in the declaration order of the enum members.

You may specify an alternative integral type, as follows:

public enum Direction : byte { Left, Right, Top, Bottom }

You may specify an explicit underlying value for each enum member:

public enum Direction : byte { Left=1, Right=2, Top=10, Bottom=11 }

The unassigned enum members keep incrementing from the last explicit value.

The preceding example is equivalent to the following:

public enum Direction : byte { Left=1, Right, Top=10, Bottom }

Related Tutorials