Conversion from 32 bit integer to 4 chars

Total Post:341

Points:2389
C# 
C#
 1187  View(s)
Ratings:
Rate this:
What is the best way to divide a 32 bit integer into four (unsigned) chars in C#?
  1. Post:145

    Points:1019
    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

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!