I’m getting an exception and I’m not seeing what I’m missing.
I have an object model called MyComposedModel and I’m creating a list of these by adding each element as they’re built.
I have this:
List<MyComposedModel> TheListOfModel = null;
MyComposedModel ThisObject = new MyComposedModel();
foreach (MyComposedModel in some list)
{
ThisObject.Reset() //clears all properties
....
TheListOfModel.Add(ThisObject)
}
And I’m getting Object reference not set to an instance of an object. on the Add(ThisObject) line.
What am I missing?
Thanks.
You have to initialize
TheListOfModelfirst. Instead of:do this: