BCS BCS - 1 year ago 154
C# Question

How to convert byte[] to string?

I have a

array that is loaded from a file that I happen to known contains UTF-8. In some debugging code, I need to convert it to a string. Is there a one liner that will do this?

Under the covers it should be just an allocation and a memcopy, so even if it is not implemented, it should be possible.

Answer Source
string result = System.Text.Encoding.UTF8.GetString(byteArray);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download