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.

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:

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft