How to define an enum with string value?

后端 未结 18 1415
一生所求
一生所求 2020-12-12 14:53

I am trying to define an Enum and add valid common separators which used in CSV or similar files. Then I am going to bind it to a ComboBox as a dat

18条回答
  •  旧时难觅i
    2020-12-12 15:06

    For a simple enum of string values (or any other type):

    public static class MyEnumClass
    {
        public const string 
            MyValue1 = "My value 1",
            MyValue2 = "My value 2";
    }
    

    Usage: string MyValue = MyEnumClass.MyValue1;

提交回复
热议问题