I need Lambda query to filter dates from list and return Max Date. If the list does not satisfy the filter then should return a null value. This is my code, need a shorter version ->
var a = Dates.Where(x => x >= DateTime.Now).Select(x => x);
if(a.Count > 0)
{
return a.Max();
}
else return null;
The value returned to is in DateTime? format which shows error "Embedded statement cannot be a declaration or labeled statement".