Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Convert from byte[] to int and int to byte[]
Message
From
06/01/2005 18:03:00
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00974405
Message ID:
00974878
Views:
19
Yes same feeling here. Forest hides the trees:)
Cetin

>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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform