Hello, I've written a class, and I've created an instance. When I try to debug it gives me an error and I really don't understand what that means. I looked at some other web sites but I don't understand what do I have to do. Can somebody please help me?
This is the class code:
namespace WindowsApplication1
{
public class Field
{
private bool[,] matrix = new bool[Const.ROW, Const.COLUMN];
public Field()
{
initializeField();
}
public void initializeField()
{
bool temp = true;
for (int i = 0; i < Const.ROW; i++)
for (int j = 0; j < Const.COLUMN; j++)
{
if (i > 0)
temp = !matrix[i - 1, j];
matrix[i - 1, j] = new bool(temp);
temp = !temp;
}
}
public bool[,] getField()
{
return matrix;
}
public void setElement(int i, int j)
{
matrix[i, j] = !matrix[i, j];
try
{
matrix[i - 1, j] = !matrix[i - 1, j];
}
catch (IndexOutOfRangeException)
{ }
try
{
matrix[i + 1, j] = !matrix[i + 1, j];
}
catch (IndexOutOfRangeException)
{ }
try
{
matrix[i, j - 1] = !matrix[i, j - 1];
}
catch (IndexOutOfRangeException)
{ }
try
{
matrix[i, j + 1] = !matrix[i, j + 1];
}
catch (IndexOutOfRangeException)
{ }
}
public Boolean getElement(int i, int j)
{
return matrix[i, j];
}
}
}
Const is a class that I use to store some constant values e.g. size of rows and columns, so I can modify that values easily later.
Field class is instantiated in the form class (Windows Application Form).
Thanks