BitConverter.GetBytes(int)和BitConverter.ToString 方法 (Byte[])

BitConverter.ToString 方法 (Byte[])

网址:https://msdn.microsoft.com/zh-cn/library/3a733s97(v=vs.110).aspx

BitConverter.GetBytes(int)

网址:http://www.cnblogs.com/skyivben/archive/2011/01/14/1935594.html

一、

byte[ ] arrayOne = {
             0,   1,   2,   4,   8,  16,  32,  64, 128, 255 };
Console.WriteLine( BitConverter.ToString(arrayOne) );
输出:00-01-02-04-08-10-20-40-80-FF

二、
long n = 0x1234567890ABCDEF;
Console.WriteLine(n.ToString("X") + ": " + BitConverter.ToString(BitConverter.GetBytes(n)));
输出:1234567890ABCDEF: EF-CD-AB-90-78-56-34-12

转换为的数组是:int的低位开始
posted @ 2017-06-30 15:43  雪芹  阅读(2227)  评论(0编辑  收藏  举报