Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question

Status
Not open for further replies.

Luzian

Programmer
Nov 27, 2005
103
US
Imagine I have 2 bytes that mean nothing when separated, but must be, because these bytes are in a file in binary format. When I read the file, these 2 bytes must actually be an integer16, but this is just a simple example, there are times when I'll need 4 bytes to be an integer32. How do I do this?
 
Use the BitConverter class, which has a ToInt16 method, as well as a ToInt32 method. Pass it a byte array containing your bytes, and it will return you the correct type.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top