Skip to content

Instantly share code, notes, and snippets.

@shiftkey
Last active December 16, 2015 16:39
Show Gist options
  • Save shiftkey/5464745 to your computer and use it in GitHub Desktop.
Save shiftkey/5464745 to your computer and use it in GitHub Desktop.
LINQ-splaining
public static void Main() {
var found = elements.Where(e => e == "foo");
// could be described as:
// - found is elements where e equals foo
// - found equals elements where e equals foo
var match = elements.FirstOrDefault(e => e > 0);
// could be described as:
// - match equals elements first or default where e is greater than 0
// - match equals first or default in elements where e is greater than 0
var viewModels = models.Select(m => CreateViewModel(m));
// could be described as:
// - viewModels is models select CreateViewModel
// - viewModels is models selecting CreateViewModel
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment