description | title | ms.date | helpviewer_keywords | ms.assetid | |||||
---|---|---|---|---|---|---|---|---|---|
Learn more about: How to: Convert Strings into an Array of Bytes in Visual Basic |
How to: Convert Strings into an Array of Bytes |
07/20/2015 |
|
f477d35c-a3fc-4a30-b1d4-cd0d353aae1d |
This topic shows how to convert a string into an array of bytes.
This example uses the xref:System.Text.Encoding.GetBytes%2A method of the xref:System.Text.Encoding.Unicode%2A?displayProperty=nameWithType encoding class to convert a string into an array of bytes.
[!code-vbVbVbalrStrings#74]
You can choose from several encoding options to convert a string into a byte array:
-
xref:System.Text.Encoding.ASCII%2A?displayProperty=nameWithType: Gets an encoding for the ASCII (7-bit) character set.
-
xref:System.Text.Encoding.BigEndianUnicode%2A?displayProperty=nameWithType: Gets an encoding for the UTF-16 format using the big-endian byte order.
-
xref:System.Text.Encoding.Default%2A?displayProperty=nameWithType: Gets an encoding for the system's current ANSI code page.
-
xref:System.Text.Encoding.Unicode%2A?displayProperty=nameWithType: Gets an encoding for the UTF-16 format using the little-endian byte order.
-
xref:System.Text.Encoding.UTF32%2A?displayProperty=nameWithType: Gets an encoding for the UTF-32 format using the little-endian byte order.
-
xref:System.Text.Encoding.UTF7%2A?displayProperty=nameWithType: Gets an encoding for the UTF-7 format.
-
xref:System.Text.Encoding.UTF8%2A?displayProperty=nameWithType: Gets an encoding for the UTF-8 format.
- xref:System.Text.Encoding?displayProperty=nameWithType
- xref:System.Text.Encoding.GetBytes%2A
- How to: Convert an Array of Bytes into a String in Visual Basic