How to: Convert an Array of Bytes into a String in Visual Basic

This topic shows how to convert the bytes from a byte array into a string.

Example

This example uses the GetString method of the Encoding.Unicode encoding class to convert all the bytes from a byte array into a string.

Private Function UnicodeBytesToString(
    ByVal bytes() As Byte) As String

    Return System.Text.Encoding.Unicode.GetString(bytes)
End Function

You can choose from several encoding options to convert a byte array into a string:

See also