Using the LegalDoorStates Enumeration : enums Definition « Data Type « C# / CSharp Tutorial






public enum LegalDoorStates
{
    DoorStateOpen,
    DoorStateClosed
}
   
class DoorController
{
    private LegalDoorStates CurrentState;
   
    public LegalDoorStates State
    {
        get
        {
            return CurrentState;
        }
   
        set
        {
            CurrentState = value;
        }
    }
}
   
class MainClass
{
    public static void Main()
    {
        DoorController Door;
   
        Door = new DoorController();
   
        Door.State = LegalDoorStates.DoorStateOpen;
    }
}








2.40.enums Definition
2.40.1.Define Enums
2.40.2.Using the LegalDoorStates Enumeration
2.40.3.Comparing Enumeration Values with CompareTo()
2.40.4.Retrieving an Enumeration Name with GetName()