enum set to string and get sting value when need

前端 未结 5 1381
旧时难觅i
旧时难觅i 2021-01-12 06:32

I don\'t know how to do this
I want code like following

enum myenum
{
    name1 = \"abc\",
    name2 = \"xyz\"
}

and check it

5条回答
  •  离开以前
    2021-01-12 07:10

    According to here what you are doing is not possible. What you could do maybe would be to have a static class full of constants, maybe something like so:

    class Constants
    {
        public static string name1 = "abc";
        public static string name2 = "xyz";
    }
    
    ...
    
    if (Constants.name1 == "abc")...
    

提交回复
热议问题