Enumeration and Structures in C#


An enumeration is a user-defined integer type which provides a way for attaching names to numbers. It increases the comprehensibility of the code. The enum keyword automatically enumerates a list of words by assigning them values 0, 1, 2, and so on. It has the following syntax:

enum Shape


Structures are referred to as structs. A struct in C# provides a unique way of packing together data of different types. It is a convenient tool for handling a group of logically related data items. It creates a template that may be used to define its data properties. Structs are declared using the struct keyword. It has the following syntax:

struct struct-name
data member1;
data member2;