I have the following code:
namespace Rextester
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //Your code goes here
            var obj=(person)Activator.CreateInstance(typeof(person));
            Console.WriteLine(obj);
        }
    }
     public class person
        {
            public int id { get; set; }
            public string name { get; set; }
            public DateTime dob { get; set; }
            public override string ToString()
            {
                return id.ToString() + " " + name + " " + dob.ToString();
            }
        }
}
which yields the following output:
0  1/1/0001 12:00:00 AM
However, if change the person.ToString() to the following:
public override string ToString()
{
        return id.ToString() + " " + name.ToString() + " " + dob.ToString();
}
I get the following error:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Rextester.person.ToString()
Can someone shed some light on it.
Edited
 
     
    