Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Convert from byte[] to int and int to byte[]
Message
 
To
05/01/2005 16:35:04
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00974405
Message ID:
00974549
Views:
33
Cetin,
Thanks for the sample code. BitConverter was exactly what I needed. I knew there had to be something out there that would do what I wanted. The only problem is that there are sooooooooo many classes in the framework, and that can be both a blessing and a curse. It is a blessing most of the time though.

Einar
>Einar,
>Use BitConverter class as Zakaria pointed:
>
using System;
>class quickTest
>{
>   static void Main() {
>
>   System.Int64 paraInt64 = 4294967295;
>   System.Int32 iValue = 42000;
>
>   System.Byte[] bValue1 = BitConverter.GetBytes(iValue);
>   System.Byte[] bValue2 = BitConverter.GetBytes(paraInt64);
>
>   Console.WriteLine("Int sizes {0} and {1}",bValue1.Length,bValue2.Length);
>
>   int iRetVal1 = BitConverter.ToInt32(bValue1,0);
>   long iRetVal2 = BitConverter.ToInt64(bValue2,0);
>
>   Console.WriteLine("Values back: {0} and {1}",iRetVal1,iRetVal2);
>}}
Cetin
Semper ubi sub ubi.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform