[VB.NET] Array to String ?

Worrow

Regular
Joined
Jul 10, 2003
Messages
68
Is there any way to convert an array of byte to string without making several chrw() call?

Thanks in advance.
 
given an array of bytes held in b() somethging similar to the following should work
Visual Basic:
Imports System.IO

Dim ms as new MemoryStream(b)
dim sr as new StreamReader(ms)
dim s as string = sr.ReadToEnd()
 
You could also do something like this:
Visual Basic:
Dim b(3) As Byte
b(1) = 97
b(2) = 97
b(3) = 97
b(0) = 97
Dim s As String = System.Text.ASCIIEncoding.ASCII.GetString(b)
Now s will contain "aaaa".
 
Back
Top