This is the code I have. I get an error on line 15 whne I enter any number. Combiantions of values I have tried for n and m include 4,5|9,9 etc.
int m = 0, n = 0;
int[,] arr = new int[n, m];
Console.WriteLine("value for n: ");
n = int.Parse(Console.ReadLine());
Console.WriteLine("\nvalue for m: ");
m = int.Parse(Console.ReadLine());
//giving arr values
Console.WriteLine("\nenter values for arr; ");
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
arr[i, j] = int.Parse(Console.ReadLine());
}
}
Exact error message
System.IndexOutOfRangeException: 'Index was outside the bounds of the array.'
Image: Image
I belive I know how multidimensional arrays work, however I might be missing something. Any help would be appriciated.