The Code below gives the output of reverse diagonal values in a 2d Array. Output is:
3,5,7
int[,] array2d2 = {
{1,2,3},
{4,5,6},
{7,8,9}
};
int i = 0;
while (i <= 2)
{
for (int j = 2; j >= 0; j--)
{
Console.WriteLine(array2d2[i,j]);
i++;
}
}
If my understanding is right, the increment operator(i) in the nested for loop, breaks the for loop by moving to the while loop and increment it by 1 and then continue the iteration. It already gave the output I wanted. My question, Is this the right way or my understanding is wrong?
I'm a beginner in C#.