I’m trying to convert a xml character entity to a C# char…
string charString = "₁".Replace("&#", "\\").Replace(";", "");
char c = Convert.ToChar(charString);
I have no idea why it is failing on the Convert.Char line. Even though the debugger shows charString as "\\\\x2081" it really is "\x2081", which is a valid Unicode character. The exception is too many characters.
The documentation for
ToChar(string)is quite readable:Also:
It will not convert a hex representation of your character into said character. It will take a one-character string and give you that character back. The same as doing
s[0].What you want is: