private int[, ,] table = new int[4 , 5 , 5]{
{{0,6,2,6,4},{2,2,4,2,8},{4,4,8,4,6},{6,6,2,6,4},{8,8,6,8,2}},
{{0,2,8,8,4},{2,4,6,6,8},{4,8,2,2,6},{6,2,8,8,4},{8,6,4,4,2}},
{{0,4,2,4,4},{2,8,4,8,8},{4,6,8,6,6},{6,4,2,4,4},{8,2,6,2,2}},
{{0,8,8,2,4},{2,6,6,4,8},{4,2,2,8,6},{6,8,8,2,4},{8,4,4,6,2}}
};
我想要这张桌子:
k|l 0 1 2 3 4
0 06264 22428 44846 66264 88682
1 02884 24668 48226 62884 86442
2 04244 28488 46866 64244 82622
3 08824 26648 42286 68824 84462
感谢帮助
最佳答案 你的宣言没有错.它编译得很好,我可以写这样的东西:
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 5; j++)
{
for (int k = 0; k < 5; k++)
{
var x = table[i, j, k];
}
}
}
更新:确定你可以缩短一点点.由于数组维度由初始值给出,因此您可以这样写:
private int[,,] table = new [,,]{
<your numbers go here>
};