How to print 2D array to console in C#

后端 未结 10 1603
野性不改
野性不改 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:22

    you can print it all on one line

    int[,] array2D = new int[,] { { 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 } };
    Console.WriteLine(String.Join(" ", array2D.Cast()));
    

    output

    1 2 3 4 5 6 7 8
    

提交回复
热议问题