Can somebody help with this snippet of code which has an exception. It always stacks on [2,0] index. I just can't figure out how to solve this. I have added a screenshot below.
private Matrix GridToMatrix(DataGridView grid)
{
var matrix = new double[grid.RowCount, grid.ColumnCount];
for (int i = 0; i < grid.RowCount; i++)
{
for (int j = 0; j < grid.ColumnCount; j++)
{
matrix[i, j] = Convert.ToSingle(grid[i, j].Value);
}
}
return new Matrix(matrix);
}