How to set space on Enum

后端 未结 14 1450
栀梦
栀梦 2020-11-29 08:00

I want to set the space on my enum. Here is my code sample:

public enum category
{
    goodBoy=1,
    BadBoy
}

I want to set



        
14条回答
  •  离开以前
    2020-11-29 08:30

    Why don't you use ToString() ?

    I mean that when use ToString(),it gives the enum value. Just you have to add some identifier to catch space.For example:

    public enum category
    {
       good_Boy=1,
       Bad_Boy
    }
    

    When you get an enum in codes like category a = ..., you can use ToString() method. It gives you value as a string. After that, you can simply change _ to empty string.

提交回复
热议问题