Possible Duplicate:
LINQ: Max or Default?
I have some LINQ to filter DateTime
vars.
List<DateTime> lst1 = new List<DateTime>();
//.... add DataTime here
var d = lst1.Where(q => q <= DateTime.Now).Max();
And if I have no matched item the exceptions occurs.
I need to get empty d
or at least null
and I don't need exception here at all.
How do I can fix it?
Thank you!