Depends on how your string is encoded in the byte[], is it UTF8, ASCII...?
Use the classes derived from the System.Text.Encoding class such as
System.Text.UTF8Encoding.
class Program {
static void Main() {
System.Text.Encoding utf = new System.Text.UTF8Encoding();
string str = "hello";
byte[] bin = utf.GetBytes(str);
string strCopy = utf.GetString(bin);
}
}
Patrick Smacchia
MVP.NET
Author of Practical .NET2 and C#2
http://www.PracticalDOT.NET
Author of NDepend:
http://www.NDepend.com
"David" <Da*************@hotmail.com> a écrit dans le message de news:
e%****************@TK2MSFTNGP12.phx.gbl...
Hi,
how to convert a char array(byte[]) to a string variable?
byte[] buffer;
string strTest;
/*the blow codes all get type of 'buffer': System.Byte[]!
strTest = buffer.ToString()
strTest = System.Convert.ToString(buffer)
*/
Thanks.