I forgot! If I have an array of chars[], how can I show them in a textbox without System.Char[] being shown when I do:
theChars.ToString();
?
Printable View
I forgot! If I have an array of chars[], how can I show them in a textbox without System.Char[] being shown when I do:
theChars.ToString();
?
Use Encoding.GetString().
Example:
Code:string s = (new System.Text.ASCIIEncoding()).GetString(chars);
that doesnt work and is that not overkill?
Sorry.
This works:
I thought there was an easier way too but I've forgotten myself.Code:char[] chars = { 'H', 'e', 'l', 'l', 'o' };
ASCIIEncoding a = new ASCIIEncoding();
byte[] bytes = a.GetBytes(chars);
string s = a.GetString(bytes);
Console.WriteLine(s);
How about:
Code:char[] chars = { 'H', 'e', 'l', 'l', 'o' };
MessageBox.Show (new string(chars));