How can I use a special char in a C# enum?
.net, enums, special-characters
Solution
Enum members shouldn't be used for user interface display purposes. They should be mapped to a string in order to get displayed. You can create a string array (or a dictionary) that maps each enum member to a string for user interaction.
That said, to answer your question directly, you can use `\uxxxxV` were `xxxx` is the hexadecimal number representing the Unicode code point for `%`. This is far from recommended. As Henk points out, this won't work for `%` as it's not in Unicode classes Lu, Ll, Lt, Lm, Lo, Nl, Mn, Mc, Nd, Pc, Cf (letters, digits, connecting, and formatting characters). Only these characters are acceptable for identifiers.
Problem
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?