Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 4.0 aka C# 2010 > BOOK: Professional C# 4.0 and .NET 4
| Search | Today's Posts | Mark Forums Read
BOOK: Professional C# 4.0 and .NET 4
This is the forum to discuss the Wrox book Professional C# 4.0 and .NET 4 by Christian Nagel, Bill Evjen, Jay Glynn, Karli Watson, Morgan Skinner; ISBN: 9780470502259
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional C# 4.0 and .NET 4 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 12th, 2010, 07:38 PM
Friend of Wrox
Points: 660, Level: 9
Points: 660, Level: 9 Points: 660, Level: 9 Points: 660, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2005
Location: St. Louis, , .
Posts: 101
Thanks: 0
Thanked 1 Time in 1 Post
Default How do you convert an integer to two bytes in C#?

How do you convert an integer to two bytes in C#?
I have googled around but no answer really works. At least none I found.
 
Old April 15th, 2011, 04:51 PM
Wrox Author
Points: 1,163, Level: 13
Points: 1,163, Level: 13 Points: 1,163, Level: 13 Points: 1,163, Level: 13
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2010
Location: Austria
Posts: 175
Thanks: 3
Thanked 53 Times in 53 Posts
Default

an integer consists of 4 bytes. Not sure which two of the four you want to ignore. To get four bytes from an integer:
Code:
            byte[] bytes = BitConverter.GetBytes(number);
Christian
__________________
Christian
CN innovation
Visit my blog at: csharp.christiannagel.com
Follow me on twitter: @christiannagel
The Following User Says Thank You to ChristianNagel For This Useful Post:




Similar Threads
Thread Thread Starter Forum Replies Last Post
hit counter (integer length from bytes to mega bytes) sandeepgreaternoida BOOK: Professional PHP 5 ISBN: 978-0-7645-7282-1 0 May 9th, 2009 03:05 AM
Convert bytes to byte[] array d-mart Java Basics 4 April 24th, 2009 10:09 AM
convert 4 bytes to bit array Vinny_68 Pro Visual Basic 2005 1 March 21st, 2007 05:40 PM
convert bytes[] into base64binary in asp.net bharat_agarwal XSLT 1 June 20th, 2006 02:04 AM
convert string to integer kcheung Classic ASP Databases 1 July 28th, 2003 04:39 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.