ConvertDataTypes.comConvert data types programming in one click !

Convert String to Byte() in VB.net

    59269 hits
  • Dim vIn As String = "FOO"
  • Dim vOut() As Byte = System.Text.Encoding.UTF8.GetBytes(vIn)
  • 'Note : if the String 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