c# int[]转byte[]
byte[]转int[]
数据互转
可以扩展成其他的数组转byte int[] intArray = new int[3];
intArray[0] = 511;
intArray[1] = 512;
intArray[2] = 513;
byte[] result = new byte[intArray.Length * sizeof(int)];
Buffer.BlockCopy(intArray, 0, result, 0, result.Length);
//下面的是反转
int[] ints = new int[result.Length / sizeof(int)];
Buffer.BlockCopy(result, 0, ints, 0, result.Length);
foreach(var item in ints)
{
Console.WriteLine(":::::" + item);
}
本文介绍如何在C#中实现int数组与byte数组之间的相互转换,包括使用Buffer.BlockCopy方法的具体步骤,并提供了完整的示例代码。
1207

被折叠的 条评论
为什么被折叠?



