using System.Collections.Generic;
public static void Main()
Console.WriteLine("Setting Nullable Date Field");
var record = new Employee();
Console.WriteLine($"Default Nullable DateTime Value: {record.Dob}, record.Dob.HasValue? {record.Dob.HasValue}");
Console.WriteLine($"Default Nullable DateTime Value: {record.Dob}, record.Dob.HasValue? {record.Dob.HasValue}");
List<string> tests =new List<string>();
for(int i = 0; i < tests.Count; i++)
string dateString = tests[i];
record.Dob = DateTime.Parse(dateString);
Console.WriteLine($"Read DateTime Value: { record.Dob }");
Console.WriteLine($"Test #{i+1} doesn't work.");
Console.WriteLine(ex.Message);
foreach (var test in tests)
string dateString = test;
if (DateTime.TryParse(dateString, out birthDate))
Console.WriteLine($"Read DateTime Value: { record.Dob }");
public DateTime? Dob {get;set;}