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 }
2.1m questions
2.1m answers
60 comments
57.0k users