I am using below code to check null value for Datetime , when modifieddate has value it works fine but when any of the value for modifieddate is null it breaks saying "Object reference not set". How i can handle it ?
public DateTime? modifiedDate { get; set; }
var lst = outObject.response.docs.Select(b =>
new finalOutput {modifiedDate = b.last_modified[0].HasValue ? b.last_modified[0] : DateTime.Now }).ToList<finalOutput>();
I tried as suggested in the link, it does not work
modifiedDate = b.last_modified[0].GetValueOrDefault(DateTime.Now) //Object reference error