Wednesday, 2 October 2013

C# Enum

C# Enum

Here is the C# Enum Defination and Example. It is not provided by any Faculty of APTECH. This is uploaded by me after searching on Internet.


Enums store special values. They make programs simpler. If you place constants directly where used, your C# program becomes complex. It becomes hard to change. Enums instead keep these magic constants in a distinct type.
using System;

class Program
{
    enum Importance
    {
 None,
 Trivial,
 Regular,
 Important,
 Critical
    };

    static void Main()
    {
 // 1.
 Importance value = Importance.Critical;

 // 2.
 if (value == Importance.Trivial)
 {
     Console.WriteLine("Not true");
 }
 else if (value == Importance.Critical)
 {
     Console.WriteLine("True");
 }
    }
}
Reference :


Click Here to Download My C# Enum Program

1 comments:

lingmaaki said...

More deatils about ...C# Enum

Ling

Post a Comment

 
;