How to convert byte array to string [duplicate]

Solution 1:

Depending on the encoding you wish to use:

var str = System.Text.Encoding.Default.GetString(result);

Solution 2:

Assuming that you are using UTF-8 encoding:

string convert = "This is the string to be converted";

// From string to byte array
byte[] buffer = System.Text.Encoding.UTF8.GetBytes(convert);

// From byte array to string
string s = System.Text.Encoding.UTF8.GetString(buffer, 0, buffer.Length);