For converting from string to bytes array and from bytes array to string you should use pair methods, that are using the same encoding, like in the next examples:
1.From
string
to
byte array
:
byte[] resultArray = System.Text.Encoding.UTF8.GetBytes(stringValue);
2.From
byte array
to
string
:
string stringResult = System.Text.Encoding.UTF8.GetString(byteArray);