Retrieving an Enumeration Name with GetName()
using System;
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;
string EnumName;
Door = new DoorController();
Door.State = LegalDoorStates.DoorStateOpen;
EnumName = LegalDoorStates.GetName(typeof(LegalDoorStates), Door.State);
Console.WriteLine(EnumName);
}
}
|
HTML code for linking to this page:
Related in same category :
-
-
-
|