Printing diagonal values(1,5,9) of a 2D array with nested for loop with diagonal shape

PHOTO EMBED

Sat Jan 07 2023 13:53:11 GMT+0000 (Coordinated Universal Time)

Saved by @AlferM #c#

using System;

namespace ConsoleApp1
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int[,] numbersArray =
            {
                { 1, 2, 3 },
                { 4, 5, 6 },
                { 7, 8, 9 },
            };

            //Pring Even values in the array
            for (int i = 0; i < numbersArray.GetLength(0); i++)         
            {
                for (int j = 0; j < numbersArray.GetLength(1); j++)
                {
                    if (i == j)
                    {
                        Console.Write(numbersArray[i, j]);
                    }
                    else
                    {
                        Console.Write(" ");
                    }
                }
                Console.WriteLine();
            }
        }
    }
}
content_copyCOPY