using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
// Changed from *int[,] matrix = new int[2, 2];*
int[,] matrix = new int[3, 3];
// Still getting error with "[3,3]"
matrix[0, 0] = 1;
matrix[0, 1] = 2;
matrix[0, 2] = 3;
matrix[1, 0] = 4;
matrix[1, 1] = 5;
matrix[1, 2] = 6;
matrix[2, 0] = 7;
matrix[2, 1] = 8;
matrix[2, 2] = 9;
Console.Write(matrix[0, 2]);
Console.ReadKey();
}
}
}
Here is a basic program to execute through command line.
Upon running, instead of displaying the number "3" stored in array [0,2], I am presented with this error:
System.IndexOutOfRangeException: 'Index was outside the bounds of the array.'