Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Converting from int to Byte[4]?
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00942999
Message ID:
00943007
Vues:
22
Well I guess it wasn't that hard. Here is the code (could use some cleaning up)
System.Int64 iInt = 2864434397; // equal to AABBCCDD in hexadecimal
System.Byte[] bByte = new System.Byte[4];

bByte[0] = Convert.ToByte(iInt/(256*256*256));
if (iInt/(256*256) <= 255)
{
  bByte[1] = Convert.ToByte(iInt/(256*256));
}
else
{
  bByte[1] = Convert.ToByte((iInt/(256*256))%256);
}
if (iInt/(256) <= 255)
{
  bByte[2] = Convert.ToByte(iInt/256);
}
else
{
  bByte[2] = Convert.ToByte((iInt/256)%256);
}
bByte[3] = Convert.ToByte(iInt%256);
Now this looks like a lot of work to simply convert, any comments are welcome.

Thanks,
Einar
Semper ubi sub ubi.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform