Click to See Complete Forum and Search --> : [C#] converting a Byte array to a string


jayderk
March 22nd, 2003, 03:12 PM
does anyone have any idea about how to convert a byte array to a string in C#?

SimonVega
March 22nd, 2003, 04:36 PM
Here you go:


byte[] bytes = {(byte)'H', (byte)'E', (byte)'L', (byte)'L', (byte)'O'};
Console.WriteLine(System.Text.ASCIIEncoding.ASCII.GetString(bytes));


You can also use the UnicodeEncoding class when dealing with the unicode character set.