Most of the time, when you try to assing value into object, and if the value is null, then this kind of exception occur.
Please check this link.
for the sake of self learning, you can put some check condition. like
if (myObj== null)
Console.Write("myObj is NULL");