C
Christopher Ireland
Hi -
It's funny ... this works fine:
private void button2_Click(object sender, System.EventArgs e) {
string s = "\u0075";
char c = Convert.ToChar(s);
label1.Text = c.ToString();
}
But now imagine I want to build the string s dynamically, e.g.
private void button2_Click(object sender, System.EventArgs e) {
string s1 = "00";
string s2 = "75";
string s = "\u" + s1 + s2;
char c = Convert.ToChar(s);
label1.Text = c.ToString();
}
The code as written above gives me a design-time error under "\u" which says
"Unrecognised escape sequence". If I change "\u" to @"\u" I now get the
following runtime exception:
An unhandled exception of type 'System.FormatException' occurred in
mscorlib.dll.
Additional information: String must be only one character long.
Can anybody please tell me how I can workaround this to dynamically build a
string (like 's') and have it converted into a Unicode character?
Thanks,
Chris.
It's funny ... this works fine:
private void button2_Click(object sender, System.EventArgs e) {
string s = "\u0075";
char c = Convert.ToChar(s);
label1.Text = c.ToString();
}
But now imagine I want to build the string s dynamically, e.g.
private void button2_Click(object sender, System.EventArgs e) {
string s1 = "00";
string s2 = "75";
string s = "\u" + s1 + s2;
char c = Convert.ToChar(s);
label1.Text = c.ToString();
}
The code as written above gives me a design-time error under "\u" which says
"Unrecognised escape sequence". If I change "\u" to @"\u" I now get the
following runtime exception:
An unhandled exception of type 'System.FormatException' occurred in
mscorlib.dll.
Additional information: String must be only one character long.
Can anybody please tell me how I can workaround this to dynamically build a
string (like 's') and have it converted into a Unicode character?
Thanks,
Chris.