How to define an enum with string value?

后端 未结 18 1414
一生所求
一生所求 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条回答
  •  生来不讨喜
    2020-12-12 15:08

    It works for me..

       public class ShapeTypes
        {
            private ShapeTypes() { }
            public static string OVAL
            {
                get
                {
                    return "ov";
                }
                private set { }
            }
    
            public static string SQUARE
            {
                get
                {
                    return "sq";
                }
                private set { }
            }
    
            public static string RECTANGLE
            {
                get
                {
                    return "rec";
                }
                private set { }
            }
        }
    

提交回复
热议问题