如何把byte【】转为int【】

sdfgrtyu 2017-04-06 08:36:00
请问如何把byte数组转为int数组
...全文
359 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
xdashewan 2017-04-06
  • 打赏
  • 举报
回复
引用 6 楼 u010941149 的回复:
就是把Msec 和数组里面的每个数相加得到short类型

short s1 = 2;
byte[] b1 = new byte[2] { 255, 255 };
int[] intArray = Array.ConvertAll<byte, int>(b1, s => Convert.ToInt32(s) + s1);
int total1 = intArray.Sum();
sdfgrtyu 2017-04-06
  • 打赏
  • 举报
回复
引用 5 楼 xdashewan 的回复:
[quote=引用 4 楼 u010941149 的回复:] Msec +intArray ??
Msec +intArray你想得出什么结果[/quote] 就是把Msec 和数组里面的每个数相加得到short类型
xdashewan 2017-04-06
  • 打赏
  • 举报
回复
引用 4 楼 u010941149 的回复:
Msec +intArray ??
Msec +intArray你想得出什么结果
sdfgrtyu 2017-04-06
  • 打赏
  • 举报
回复
引用 3 楼 xdashewan 的回复:

byte[] b1 = new byte[2] { 255, 255 };
int[] intArray = Array.ConvertAll<byte, int>(b1, s => Convert.ToInt32(s));
数组的select貌似也可以
请问把int【】转为一个一个的数值和别的数相加怎么写? short Msec = BitConverter.ToInt16(bytes, 8); int[] intArray = Array.ConvertAll<byte, int>(Data, y => Convert.ToInt32(y)); Msec +intArray ??
xdashewan 2017-04-06
  • 打赏
  • 举报
回复

byte[] b1 = new byte[2] { 255, 255 };
int[] intArray = Array.ConvertAll<byte, int>(b1, s => Convert.ToInt32(s));
数组的select貌似也可以
sdfgrtyu 2017-04-06
  • 打赏
  • 举报
回复
引用 1 楼 sp1234 的回复:
https://msdn.microsoft.com/zh-cn/library/system.bitconverter.toint32(v=vs.110).aspx
后面怎么写,要转成int数组

111,094

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧