DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2005
    Posts
    134

    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.

  2. #2
    Join Date
    Feb 2004
    Location
    Longueuil, Québec
    Posts
    577
    Google is useless

    Code:
    int i;
    byte b1;
    byte b2;
    
    i = 512;
    b1 = (byte)(i/256);
    b2 = (byte)(i % 256); // % is the modulo operator (remainder)
    Jacques Bourgeois
    JBFI
    http://www3.sympatico.ca/jbfi/homeus.htm

Similar Threads

  1. Replies: 1
    Last Post: 09-21-2010, 09:01 AM
  2. plesae help me i will cry
    By stone cold in forum VB Classic
    Replies: 6
    Last Post: 12-22-2006, 11:49 AM
  3. Replies: 3
    Last Post: 04-08-2006, 06:38 PM
  4. Physical Address of the NIC
    By eduardoms in forum Security
    Replies: 2
    Last Post: 05-06-2005, 10:26 AM
  5. How long before the next version??
    By _CAG in forum .NET
    Replies: 146
    Last Post: 08-12-2002, 10:40 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links