Mega Code Archive

 
Categories / C# / Development Class
 

Convert Unicode character to an array of bytes

using System; class GetBytesCharDemo {     const string formatter = "{0,10}{1,16}";     public static void GetBytesChar( char argument )     {         byte[ ] byteArray = BitConverter.GetBytes( argument );         Console.WriteLine( formatter, argument, BitConverter.ToString( byteArray ) );     }     public static void Main( )     {         GetBytesChar( '\0' );         GetBytesChar( 'A' );     } }