Specifying the Base Type of an Enumeration
By default, enumerations are based on the type int. But one can create an enumeration of any integer type, except for type char.
To specify a type other than int, just put the base type after the enumeration name, separated by a colon. For example, the following statement makes colors an enumeration based on byte.
enum colors : byte { Yellow, Green, Blue, red, White };
Now colors.Blue, for example, is a byte quantity.
|
| Author: Harmeet Singh Sra 06 Sep 2004 | Member Level: Silver Points : 0 |
using this method we can use only numeric data type as base type for enums. we can not specify string type data Type.
|