Mega Code Archive

 
Categories / C# / Development Class
 

Convert double to an array of bytes

using System; class GetBytesDoubleDemo {     const string formatter = "{0,25:E16}{1,30}";     public static void GetBytesDouble( double argument )     {         byte[ ] byteArray = BitConverter.GetBytes( argument );         Console.WriteLine( formatter, argument, BitConverter.ToString( byteArray ) );     }     public static void Main( )     {         GetBytesDouble( 0.0 );         GetBytesDouble( 1.0 );     } }