byte[] to char[]

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm new to C# and I wondered how to convert an Array of byte to array chars?
Provided that I have this array
byte[] a = new byte[50];

Thx.
 
byte[] a = new byte[50];

char [] cArray= System.Text.Encoding.ASCII.GetString(a).ToCharArray();
 
Shakir Hussain said:
byte[] a = new byte[50];

char [] cArray= System.Text.Encoding.ASCII.GetString(a).ToCharArray();

There's no need for the copying here - just use Encoding.GetChars.
However, there's no guarantee that ASCII is going to be the appropriate
encoding to use.
 
Back
Top