Convert byte array into a string using MemoryStream in CSharp
Description
The following code shows how to convert byte array into a string using MemoryStream.
Example
/*w w w .j a v a 2 s .c om*/
using System;
using System.IO;
using System.Text;
public static class CompressionUtility
{
public static string ConvertBytesToString(byte[] bytes)
{
string output = String.Empty;
MemoryStream stream = new MemoryStream(bytes);
stream.Position = 0;
using (StreamReader reader = new StreamReader(stream))
{
output = reader.ReadToEnd();
}
return output;
}
}