Skip to content

Instantly share code, notes, and snippets.

@nedgrady
Created May 17, 2021 20:08
Show Gist options
  • Save nedgrady/709716416fa8e65b15948ea43463360a to your computer and use it in GitHub Desktop.
Save nedgrady/709716416fa8e65b15948ea43463360a to your computer and use it in GitHub Desktop.
// Could be a captured parameter or local variable
(DateTime? from, DateTime? to) dateRange = ...
return people.Where(ThePersonWasBornWithinTheDateRange);
// Local function, capturing dateRange.
bool ThePersonWasBornWithinTheDateRange(Person person) =>
(dateRange.to == null || person.DateOfBirth <= dateRange.to)
&& (dateRange.from == null || person.DateOfBirth >= dateRange.from)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment