I have two classes:
public class SubObject {
public int id;
}
public class Object {
public SubObject[] SubObjects;
}
And I have one array:
public Object[] Objects;
When I try to instantiate this array:
public void InstantiateArrays(int objectsSize, int subObjectsSize) {
Objects = new Object[objectsSize];
foreach (Object obj in Objects) {
obj.SubObjects = new SubObject[subObjectsSize];
}
}
I am receiving this error:
An exception of type 'System.NullReferenceException' occurred in **** but was not handled in user code
Additional information: Object reference not set to an instance of an object.