Enumerations are a distinct type consisting of a set of named constants called the enumerator list. Every enumeration type has an underlying type, which can be any integral type except char.
Enumerations are integer-types that make code clearer and easier to maintain.
Example:
enum Days {Sat, Sun, Mon, Tue, Wed, Thu, Fri};
A structure is a value type and the instances or objects of a structure are created in stack. A struct can contain fields, methods, constants, constructors, properties, indexers, operators and even other structure types.
Structs are similar to clases, but are intended to be used to group similar items of data together.
Example:
struct MyStruct{
static int x = 25;
static int y = 50;
public void SetXY(int i, int j)
{
x = i;
y = j;
}
public static void ShowSum()
{
int sum = x + y;
Console.WriteLine("The sum is {0}",sum);
}
}
Understanding Structures in C#:
http://www.c-sharpcorner.com/Languag...resInCSRVS.asp
C# Programmer's Reference enum:
http://msdn.microsoft.com/library/de...ationtypes.asp
- A.Kahtava