Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#中的单字节数组到二维字节数组?_C#_Arrays_Bytearray - Fatal编程技术网

C#中的单字节数组到二维字节数组?

C#中的单字节数组到二维字节数组?,c#,arrays,bytearray,C#,Arrays,Bytearray,我有一个字节数组 byte[] d = new byte[64]; 现在我想把它转换成2d字节数组,比如 byte[,] data = new byte[8,8]; 有人能帮我吗这可能是一种方法 byte[] d = new byte[64]; byte[,] data = new byte[8,8]; int row = 0; int column = 0; for(i=0; i < d.Length; i++) { row = i%8; column = i/8;

我有一个字节数组

byte[] d = new byte[64];
现在我想把它转换成2d字节数组,比如

byte[,] data = new byte[8,8];

有人能帮我吗这可能是一种方法

byte[] d = new byte[64];
byte[,] data = new byte[8,8];

int row = 0;
int column = 0;

for(i=0; i < d.Length; i++)
{
   row = i%8;
   column = i/8;
   data [row, column] = d[i];    
}
byte[]d=新字节[64];
字节[,]数据=新字节[8,8];
int行=0;
int列=0;
对于(i=0;i
您可以使用:


像这样的怎么样

byte[] d = new byte[64];

for (byte i = 0; i < d.Length; i++)
    d[i] = i;

byte[,] data = new byte[8, 8];

Enumerable.Range(0, 8).ToList().
    ForEach(i => Enumerable.Range(0, 8).ToList().
        ForEach(j => data[i, j] = d[i * 8 + j]));
byte[]d=新字节[64];
for(字节i=0;iEnumerable.Range(0,8).ToList()。
ForEach(j=>data[i,j]=d[i*8+j]);

是的,谢谢,但需要一些编辑,如果您允许,我将在ans中进行编辑。。谢谢你或者你可以告诉我,这样我就能做到了。让它成为
d.Length
data[列,行]
这就是hanks@Drone,你真好。做出了这些改变。
byte[] d = new byte[64];

for (byte i = 0; i < d.Length; i++)
    d[i] = i;

byte[,] data = new byte[8, 8];

Enumerable.Range(0, 8).ToList().
    ForEach(i => Enumerable.Range(0, 8).ToList().
        ForEach(j => data[i, j] = d[i * 8 + j]));