C# Object reference not set to an instance of an object. Instantiating Class within a List?

You should initialize lstOrderitem property in the constructor, like this:

EDIT

public MyClass() {
    lstOrderitem = new List<OrderItem>();
}

P.S. Microsoft suggests starting the names of your properties in capital letters, to avoid confusion with member variables, which should be named starting with a lowercase letter.


It looks like you didn't initialize your reference lstOrderitem. Debug your code if your references value is null, you need to initialize lstOrderitem before using it.