Mega Code Archive

 
Categories / C# / Development Class
 

Convert Boolean value to an array of bytes

using System; class GetBytesBoolDemo {     const string formatter = "{0,10}{1,16}";     public static void GetBytesBool( bool argument )     {         byte[ ] byteArray = BitConverter.GetBytes( argument );         Console.WriteLine( formatter, argument, BitConverter.ToString( byteArray ) );     }     public static void Main( )     {         GetBytesBool( false );         GetBytesBool( true );     } }