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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top