Converting Byte() to String

  • Thread starter Thread starter Benoit
  • Start date Start date
B

Benoit

Hi, what is the most performing way to convert a byte stream to a string?

Byte() to be converted to String.

Thanks, iBen.

Sorry if it ia a double post in this newsgroup, I cannot set my first one.
 
Benoit,
Hi, what is the most performing way to convert a byte stream to a string?
By a 'byte stream' do you mean a class derived from System.IO.Stream?

Use a System.IO.StreamReader class over the Stream object with the correct
encoding passed to the constructor
Byte() to be converted to String.
Or are you referring to a Byte Array?

You can use the System.Text.Encoding class to convert an array of Bytes to a
String based on the encoding used in the byte array.

Dim bytes() As Byte
Dim s As String = System.Text.Encoding.Default.GetString(bytes)

Will convert the array of bytes based on the system's current ANSI code
page.


Hope this helps
Jay
 
Back
Top