I have declared Person class as below.
public class Person
{
public string Prefix { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public DateTime? DateOfBirth { get; set; }
}
I create an Person object.
Person _person = new Person { Prefix = "Mr", FirstName = "William", LastName = "Jonathan", DateOfBirth = DateTime.Now.AddYears(-29) };
Problem --> I got an error "Object reference not set to an instance of an object." in setting value to DateOfBirth.
Anybody help me? How to solved it?
Thank you.
Thakerng.
Sanwar RanwaPosted Jul 23, 2019, 12:23 AM
Thakerng KruabkontoPosted Jul 23, 2019, 4:56 AM
Rajanikant HawaldarPosted Jul 23, 2019, 12:23 AM
AnjuPosted Jul 23, 2019, 12:09 AM