C gets a simple instance of an enumeration value

  • 2020-05-19 05:35:46
  • OfStack

Declare an enumeration first:


 public enum Test_Enum
        {
            one = 1001, two = 1002, three = 1003, four = 1004, five = 1005, six = 1006, seven = 1007, eight = 1008, nine = 1009, zero = 1000
        }

Get the value:


 object ojb = Enum.GetName(typeof(Test_Enum),Test_Enum.eight);
 int i = (int)Test_Enum.eight;


Related articles: