如何用c#输出一个二维数组啊  输出如:int [,] array=new int[4,4] { {},{} ,{} ```};
                               for(){for  {}  Console.writeLine();}
1 2 3 4
7 8 9 4
3 6 8 6
7 5 6 1

解决方案 »

  1.   

    int[,]ary={{1,2,3,4},{5,6,7,8},.....};
    估计成吧
      

  2.   


    void Main()
    {
    int [,] array=new int[4,4] { {1,2,3,4},{7,8,9,4} ,{3,6,8,6},{7,5,6,1}};
        int m=0;
    foreach(int i in array)
    {
     m++;
     Console.Write(i+"   ");
     if(m%4==0)
      {
    Console.Write("\r\n");    
      }
    }

    }/*
    1   2   3   4   
    7   8   9   4   
    3   6   8   6   
    7   5   6   1   */
      

  3.   

    [code=C#] int [,] array=new int[4,4]{{1,2,3,4},{5,6,7,8},{2,3,4,5},{7,5,4,5}};
           
                for (int i = 0; i < array.GetLength(0); i++)
                {
                    for (int j = 0; j < array.GetLength(1); j++)
                        Console.Write(array[i, j] + "\t");
                    Console.WriteLine("");
                }  
                Console.Read();code]
      

  4.   


     int [,] array=new int[4,4]{{1,2,3,4},{5,6,7,8},{2,3,4,5},{7,5,4,5}};
           
                for (int i = 0; i < array.GetLength(0); i++)
                {
                    for (int j = 0; j < array.GetLength(1); j++)
                        Console.Write(array[i, j] + "\t");
                    Console.WriteLine("");
                }  
                Console.Read();
    //结果:
     1 2 3 4 
     5 6 7 8
     2 3 4 5
     7 5 4 5