I have a very beginning C# question. Suppose I have a class called GameObject, and I want to create an array of GameObject entities. I could think
The issue here is that you've initialized your array, but not its elements; they are all null. So if you try to reference houses[0], it will be null.
Here's a great little helper method you could write for yourself:
T[] InitializeArray(int length) where T : new()
{
T[] array = new T[length];
for (int i = 0; i < length; ++i)
{
array[i] = new T();
}
return array;
}
Then you could initialize your houses array as:
GameObject[] houses = InitializeArray(200);