C# program using 2D array to print a matrices.

Category > CSHARP || Published on : Sunday, November 1, 2020 || Views: 697 || 2D array to print a matrices


Here Pawan Kumar will explain how to write C# program using 2D array to print a matrices.

using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication6
{
    class TwoDArray
    {
        static void Main(string[] args)
        {
            int[,] a;
            a = new int[2, 3];
            a[0, 0] = 50;
            a[0, 1] = 60;
            a[0, 2] = 70;
            a[1, 0] = 80;
            a[1, 1] = 90;
            a[1, 2] = 100;
            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 3; j++)
                Console.Write(" " + a[i, j]);
                Console.WriteLine();
            }
            Console.WriteLine("press any key to exit");
            Console.ReadLine();
        }
    }
}