enum set to string and get sting value when need

前端 未结 5 1410
旧时难觅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条回答
  •  猫巷女王i
    2021-01-12 07:00

    This was discuessed here before, but can't find it. Short version: you can't give enum members string values. You can use the member names as the values, but often this isn't what you want. Please follow this link for a guide how to use attributes to annotate string values to enum members.

提交回复
热议问题