Conversion from 32 bit integer to 4 chars

Total Post:341

Points:2389

C# 
C#
 1390  View(s)
Ratings:
Rate this:
What is the best way to divide a 32 bit integer into four (unsigned) chars in C#?
  1. Re: Conversion from 32 bit integer to 4 chars

    Hi ankit,

    int value = 0x48454C4F;

    Console.WriteLine(Encoding.ASCII.GetString(

      BitConverter.GetBytes(value).Reverse().ToArray()

    ));

Answer

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.