c# 二维数组添加值

如题所述

第1个回答  推荐于2016-04-29
一、
int[,] two = new int[2,2]; //声明二维数组
two = {{0, 0} ,{0, 1} ,{1, 0} ,{1, 1}}; //数组添加值
二、
int[,] two = new int[2,2]; //声明二维数组
for (int i = 0; i < two.GetLength(0); i++) //遍历第一维
{
for (int j = 0; j < two.GetLength(1); j++) //遍历第二维
{
two[i, j] = 1; //为数组内每个值付上1
}
}本回答被网友采纳
第2个回答  2012-03-14
int[,] temp=new int[2,2];
temp={{0,0},{0,1},{1,0},{1,1}};
第3个回答  2012-03-14
使用两个循环就可以了
相似回答