How to print 2D array to console in C#

后端 未结 10 1608
野性不改
野性不改 2020-12-06 22:59

I dont\'t have any code for this, but I do want to know how I could do this. I use visual studio 2010 C# if that matters.

Thanks

Jason

10条回答
  •  星月不相逢
    2020-12-06 23:17

    Do it like this:

    static public void Print2DArray(int[][] A)
    {
        foreach (int[] row in A)
        {
            foreach (int element in row)
            {
                  Console.Write(element.ToString() + " ");
            }
            Console.WriteLine();
        }
    }
    

提交回复
热议问题