ConvertDataTypes.comConvert data types programming in one click !

Convert byte[] to string in C#

    14009 hits
  • byte[] vIn = new byte[]{'F','O','O'};
  • string vOut = System.Text.Encoding.UTF8.GetString(vIn);
  • /*
  • Note : if the byte array is encoded with another encoding,
  • replace UTF8 by :
  • System.Text.Encoding.ASCII;
  • System.Text.Encoding.BigEndianUnicode;
  • System.Text.Encoding.Unicode;
  • System.Text.Encoding.UTF32;
  • System.Text.Encoding.UTF7;
  • System.Text.Encoding.UTF8;
  • System.Text.Encoding.Default : based on the Windows API GetACP
  • which returns the Windows ANSI code page identifier for the
  • operating system
  • */