I know I can index a rectangular array with for and foreach loops
but I feel like I'm missing some syntax knowledge on how to return one specific whole row of an array.
For example if my [3,6] array was like this
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
And I want to just print that middle row to the console, is there an easier way to achieve this than using:
int[,] rectArray = new int[3, 6]
{
{1, 2, 3, 4, 5, 6 },
{1, 2, 3, 4, 5, 6 },
{1, 2, 3, 4, 5, 6 }
};
Console.WriteLine("{0} {1} {2} {3} {4} {5}",
rectArray[0, 0],
rectArray[0, 1],
rectArray[0, 2],
rectArray[0, 3],
rectArray[0, 4],
rectArray[0, 5]);
I was hoping there might be something I could do like:
Console.Writeline(rectArray[0,]);
but that does not work for obvious reasons.