Int <-> Byte Array ? 
Author Message
 Int <-> Byte Array ?

I have to convert an int into an Intel format byte array and then from the
byte array back into an int.  I have no idea how to do this in C#.  Any
ideas would be greatly appreciated.


Sat, 23 Oct 2004 07:22:27 GMT  
 Int <-> Byte Array ?

Quote:
> I have to convert an int into an Intel format byte array and then from the
> byte array back into an int.  I have no idea how to do this in C#.  Any
> ideas would be greatly appreciated.

Something like this, maybe?
int answer = 42;
byte[] answerBytes = BitConverter.GetBytes( answer );

//...

answer = BitConverter.ToInt32( answerBytes );

--
Arild Fines

- The computer was conceived as a tool to reduce complexity. Some people
found this loss of complexity unacceptable, and developed UNIX to
reintroduce it.



Sat, 23 Oct 2004 07:34:16 GMT  
 Int <-> Byte Array ?
THANK YOU!

Quote:


> > I have to convert an int into an Intel format byte array and then from
the
> > byte array back into an int.  I have no idea how to do this in C#.  Any
> > ideas would be greatly appreciated.

> Something like this, maybe?
> int answer = 42;
> byte[] answerBytes = BitConverter.GetBytes( answer );

> //...

> answer = BitConverter.ToInt32( answerBytes );

> --
> Arild Fines

> - The computer was conceived as a tool to reduce complexity. Some people
> found this loss of complexity unacceptable, and developed UNIX to
> reintroduce it.



Sat, 23 Oct 2004 07:34:45 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. newbie: int->byte[]->int?

2. <<<<<<<Parsing help, please>>>>>>>>

3. File Format conversion, ascii freeform -->.csv <-->.wk1<-->dbf<-->?HELP

4. <<<>>>Need C code advice with functions and sorting.<<<>>>

5. <><><>HELP<><><> PCMCIA Motorola Montana 33.6

6. >>>Windows Service<<<

7. BUG?: vector <int,allocator<int>> compiler whitespace error [newbie BEGS your help!]

8. BUG?: vector <int,allocator<int>> compiler whitespace error [newbie BEGS your help!]

9. byte[] <----> Char

10. FORTRAN<--> C byte parameter

11. proposal: <basic.h>, <pascal.h>, <fortran.h>, <cobol.h>

12. <<<< C Grammar for yacc needed >>>>

 

 
Powered by phpBB® Forum Software