Iterate through 2 dimensional array c#

后端 未结 7 1514
悲&欢浪女
悲&欢浪女 2020-12-03 16:37
for(int k=0;k <= odds.GetLength(-1);k++)

The above line of code is supposed to iterate through a two dimensional array of type Double but keeps

7条回答
  •  不思量自难忘°
    2020-12-03 17:34

    string[,] arr = new string[2, 3];
            arr[0, 0] = "0,0";
            arr[0, 1] = "0,1";
            arr[0, 2] = "0,2";
    
            arr[1, 0] = "1,0";
            arr[1, 1] = "1,1";
            arr[1, 2] = "1,2";
    
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j < arr.GetLength(1); j++)
                {
                    Response.Write(string.Format("{0}\t", arr[i, j]));
                }
                Response.Write("
    "); }

提交回复
热议问题