A
Andrea
how can I convert a byte[] to a string ?
Any idea?
Andrea
Any idea?
Andrea
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Andrea said:how can I convert a byte[] to a string ?
Any idea?
Andrea
Andrea said:how can I convert a byte[] to a string ?
Any idea?
Andrea
Andrea said:how can I convert a byte[] to a string ?
Any idea?
Erik Frey said:Andrea said:how can I convert a byte[] to a string ?
Any idea?
Andrea
How are the characters encoded in the byte array? You need to examine the
System.Text.Encoding class and its related classes:
System.Text.ASCIIEncoding, System.Text.UnicodeEncoding. Here's a basic
example, if the byte array is ASCII:
System.Text.ASCIIEncoding AE = new System.Text.ASCIIEncoding();
byte[] ByteArray = { 69, 110, 99, 111, 100, 105, 110, 103, 32, 83, 116,
114, 105, 110, 103, 46 };
char[] CharArray = AE.GetChars(ByteArray);
string s = new string(CharArray);
MessageBox.Show(s);
MessageBox.Show (Encoding.ASCII.GetString(bytes));
There's no need to create a new ASCIIEncoding, or to get a character
array and then create a string from that.

Erik Frey said:That's what I get for cutting and pasting from MSDN![]()
Jon Skeet said:Could you let me know which MSDN page it is? I'm more than happy to
write an email suggesting a change...
Erik Frey said:Encoding Base Types:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgu
ide/html/cpconencodingbasetypes.asp
Cheers.
The article places an emphasis on coverting to chars, so the methodology may
be appropriate (if roundabout).
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.