I have a byte[] array that is loaded from a file that I happen to known contains UTF-8.
byte[]
In some debugging code, I need to convert it to a string. Is
A general solution to convert from byte array to string when you don't know the encoding:
static string BytesToStringConverted(byte[] bytes) { using (var stream = new MemoryStream(bytes)) { using (var streamReader = new StreamReader(stream)) { return streamReader.ReadToEnd(); } } }