Look at your code, and pay attention to every use of
k
:
int k = 1;
int[,] d = new int[k, 3];
d[k, i] = Convert.ToInt32(b);
if (k < 3)
k++;
So you start with
k = 1
, allocate an array with one row by three columns...and then try to access the second row...
C# array indices are zero based: so the array you declared had three elements at [0, 0], [0, 1], and [0, 2]