Skip to content

Instantly share code, notes, and snippets.

@prashantvc
Created August 4, 2013 18:02
Show Gist options
  • Save prashantvc/6151228 to your computer and use it in GitHub Desktop.
Save prashantvc/6151228 to your computer and use it in GitHub Desktop.
var items = new[] { 1, 2, 3, 4, 5, 2 };
Func<int, bool> predicate = delegate(int i)
{
Console.WriteLine(i);
return i == 2;
};
//Prints: 1 2
items.Where(predicate).FirstOrDefault();
//Prints: 1 2
items.FirstOrDefault(predicate);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment