You need to initialize the object.
It happens when you do not use the keyword "new"
Example You have a class "Car" and you want to use it somewhere in the code.
public Class Car{
public Color CarColor{ set; get; }
public int TopSpeed { set; get; }
public string Make { set; get; }
public string Model { set; get; }
}
Causing the exception like this:
Car car;
car.TopSpeed = 250;
Avoiding the excpetion like this:
Car car = new Car();
car.TopSpeed = 250;
using the "new" keyword will make the program, reserve memory, as it where, for all the variables/functions that that class needs. In this case the application will reserve memory to hold CarColor, TopSpeed, Make and Model.
If you want another car, make sure to use the "new" keyword again:
Car car2 = new Car();
otherwise you get the exception again.
Hope this helps.