Convert from byte[] to unsigned short

  • Thread starter Thread starter moni
  • Start date Start date
M

moni

hey,

When I convert a byte[] into string values I do it like this:

TextBox2.Text = System.Text.Encoding.ASCII.GetString(buffer, 0, 31);

where buffer is my byte array where my data is stored.

Can someone tell me what I would need to do , if I have to extract the
unsigned short value from my byte array??

Thanks.
 
Moni,

Call the static ToUInt16 method on the BitConverter class.

Hope this helps.
 
Thanks alot Nicholas!

Moni,

Call the static ToUInt16 method on the BitConverter class.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

moni said:
hey,

When I convert a byte[] into string values I do it like this:

TextBox2.Text = System.Text.Encoding.ASCII.GetString(buffer, 0, 31);

where buffer is my byte array where my data is stored.

Can someone tell me what I would need to do , if I have to extract the
unsigned short value from my byte array??

Thanks.
 
Back
Top