unsafe C#
unsafe void ShowBytes(byte* start, int len) { for (int i = 0; i < len; i++) { Console.Write("{0}", start[i].ToString("X2")); } Console.WriteLine(); } unsafe void ShowShort(short x) { ShowBytes((byte*)&x, sizeof(short)); } unsafe void ShowShort(int x) { ShowBytes((byte*)&x, sizeof(int)); } unsafe void ShowShort(uint x) { ShowBytes((byte*)&x, sizeof(uint)); } unsafe void ShowShort(float x) { ShowBytes((byte*)&x, sizeof(float)); } unsafe void ShowShort(char x) { ShowBytes((byte*)&x, sizeof(char)); } unsafe void show<T>(T x) { Console.Write(x.ToString()); } REF: c n blog s . com / Hope G i / p / 6901880.html