.Net C# 5 Codes on various topics & Visual Studio 2012 Source Codes available to direct download.
Working With Enumerations in C#
.Net Enumeration Basics
Enumerations or simply Enums in short provide convenient ways to create and access named numeric constants. These constants can have custom Indexable values that represent each individual element. Unlike arrays, they can have values which are not incremental in steps of ‘1’. Also, these values can be of types other than integers (which is the default) such as bytes, Boolean etc.
A single Enumeration itself has a group of values associated with it. We create an Enum Object before attempting to use the functions that are offered. This value when used with a dot operator on an Enumeration gives the state of the Enumeration Object. When we initialize new Enums of a previously defined Enum, we don’t use the new operator. The new Enums are almost immediately created and initialized to an initial value within the Enum.
Create an Enum
Subscribe to:
Posts (Atom)