For example:
public enum Unit{ KW, kV, V, Hz, %V }
In this case % is a special character. So, how can I put this char in a enum?
Even if you could do that (and it looks you can't), it probably wouldn't be a good idea, because you'd be mixing how the enum should be displayed with the program code to manipulate it. A better option would be to define an attribute (or use existing DisplayNameAttribute) and annotate your enum with names as additional meta-data:
DisplayNameAttribute
public enum Unit{ [DisplayName("Hz")] Hertz, [DisplayName("%V")] Volt }
1.4m articles
1.4m replys
5 comments
57.0k users