Convert 32-bit signed integer value to an array of bytes.
using System;
class GetBytesInt32Demo
{
const string formatter = "{0,16}{1,20}";
public static void GetBytesInt32( int argument )
{
byte[ ] byteArray = BitConverter.GetBytes( argument );
Console.WriteLine( formatter, argument, BitConverter.ToString( byteArray ) );
}
public static void Main( )
{
GetBytesInt32( 0 );
GetBytesInt32( 15 );
}
}
Related examples in the same category