您的位置:首页 > 编程语言 > C#

C# int字节 转换Byte数组 3位

2015-08-05 15:12 239 查看
C# C语言写法

public byte[] GetByteByPoint(int point)
{
byte[] array = new byte[3];

array[0] = Convert.ToByte((point & 0xff0000) >> 16);
array[1] = Convert.ToByte((point & 0xff00) >> 8);
array[2] = Convert.ToByte(point & 0xff);

return array;
}


返回3个字节 0XFF000为滤码

C# 实现

public byte[] GetByteByPoint1(int point)
{
return BitConverter.GetBytes(System.Net.IPAddress.HostToNetworkOrder(point));
}
返回 4位
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: