字节数组 byte[] 与 int型数字的相互转换

byte数组转换为int

byte[] bytes = {0xff, 0xff};

int num = BitConverter.ToInt32(bytes, 0);  // 0为字节数组开始转换的起始位置下标

 

int 转换为 byte数组

int num = 3;

byte[] bytes = BitConverter.GetBytes(num);  

 

posted @ 2020-10-30 17:05  llkj  阅读(2055)  评论(0编辑  收藏  举报