Convert a byte array to string using default encoding in CSharp
Description
The following code shows how to convert a byte array to string using default encoding.
Example
/*from w w w .jav a2s .c o m*/
using System;
using System.Collections.Generic;
using System.Text;
public class SysUtil
{
public static void Main(String[] argv){
Console.WriteLine(BytesToString(new byte[]{65,66,67,68}));
}
public static String BytesToString(byte[] bData)
{
return System.Text.Encoding.GetEncoding(0).GetString(bData);
}
}
The code above generates the following result.