Essentially I am attempting to make my own game of life in C# with a Map class whose instances contain an array of Life(Cell) objects.
However in my program attempting to check:
if (lifemap.obj[y, x].isAlive == true)
Where lifemap is an object containing an array of cell like objects
throws a System.NullReferenceException: 'Object reference not set to an instance of an object.' in visual studio.
I set that line to a breakpoint and looked in the debugger to see that my "obj" variable containing an array of Life instances has a value of null. I can't see how this could be so any help would be appreciated, my code for the constructor for the Map object is as follows:
public Map(int rows,int columns)
{
    this.columns = columns;
    this.rows = rows;
    Life[,] obj = new Life[rows, columns];
    Random rnd = new Random();
    for (int x = 0; x < columns; ++x)
        for (int y = 0; y < rows; ++y)
        {
            if (rnd.Next(100) < 50) obj[y, x] = new Life(false);
            else
            {
                obj[y, x] = new Life(true);
                ++alivecellscount;
            }
        }
}
