|
-
Sep 12th, 2006, 01:36 PM
#1
Thread Starter
PowerPoster
System.Char[]
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();
?
-
Sep 12th, 2006, 02:05 PM
#2
Re: System.Char[]
Use Encoding.GetString().
Example:
Code:
string s = (new System.Text.ASCIIEncoding()).GetString(chars);
Last edited by penagate; Sep 12th, 2006 at 02:08 PM.
-
Sep 12th, 2006, 02:11 PM
#3
Thread Starter
PowerPoster
Re: System.Char[]
that doesnt work and is that not overkill?
-
Sep 12th, 2006, 02:15 PM
#4
Re: System.Char[]
Sorry.
This works:
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);
I thought there was an easier way too but I've forgotten myself.
-
Sep 12th, 2006, 03:19 PM
#5
Re: System.Char[]
How about:
Code:
char[] chars = { 'H', 'e', 'l', 'l', 'o' };
MessageBox.Show (new string(chars));
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|