473,396 Members | 1,770 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Convert from byte[] to unsigned short

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.

Aug 8 '06 #1
2 5399
Moni,

Call the static ToUInt16 method on the BitConverter class.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"moni" <mo*******@gmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
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.

Aug 8 '06 #2
Thanks alot Nicholas!
Nicholas Paldino [.NET/C# MVP] wrote:
Moni,

Call the static ToUInt16 method on the BitConverter class.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"moni" <mo*******@gmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
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.
Aug 8 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Bryan Parkoff | last post by:
I have two variables: "char A" and "short B". I can be able to convert from A to B using explicit case conversion with no problem like "B = short (A);". Right now, I have two variables: "char T"...
5
by: kevinniu | last post by:
Hi everyone, In c#, what is the fastest way(include unsafe) to convert a array of bytes(which really contains the bytes of a double array) to a arry of double. thanks
3
by: Gordon Knote | last post by:
Hi I've got the following problem: In one of my programs I receive a string that contains a hex number (e.g. "B4"). Now, I want to convert this "number" into a var of type BYTE. How can this be...
2
by: Howard Weiss | last post by:
I am reading a file (containing short integers). To read the file, I use the following FileStream *myFile = new FileStream(FileName, FileMode::Open, FileAccess::Read); __int64 myFileSize =...
2
by: aengus | last post by:
Hi, I am looking to find out how to deal with the BYTE datatype in VC, as used below: This struct is part of the API for a Garmin GPS unit: typedef struct { unsigned char mPacketType; ...
3
by: Eric BOUXIROT | last post by:
hi, i must convert all of these eVC++ prototypes to use with VB.NET.... DLLEXPORT long F_BDO_MessageBoxOK(char *IN_title, char *IN_msg ); DLLEXPORT long F_BDO_MessageBoxOUINON(char *IN_title,...
65
by: kyle.tk | last post by:
I am trying to write a function to convert an ipv4 address that is held in the string char *ip to its long value equivalent. Here is what I have right now, but I can't seem to get it to work. ...
20
by: Manuel | last post by:
hi, I have a problem, a stupid problem. I can't declare a variable of type byte. The g++ said that i have syntactic error in this line. The code is this: byte * variable; well, i think...
7
by: farnaz.shahed | last post by:
Hi, This what I'm basically supposed to do. If i have a byte which looks like this 00010000, i need to convert it to 11110000. That would mean if any of the bit fields is 1....all the bit...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.