Skip to content

Instantly share code, notes, and snippets.

@agilejon
Created March 6, 2013 18:15
Show Gist options
  • Save agilejon/5101647 to your computer and use it in GitHub Desktop.
Save agilejon/5101647 to your computer and use it in GitHub Desktop.
// I have some list of things (typically IDs) that I want to do work on.
var fooIds = fooObjects.Select(f => f.FooId).ToList();
// #1
// This is my preference, because it's easier (for me) to spot the fact that we are taking some kind of important action.
// Examples 2 and 3 are easier to mis-read. At first glance I read them as somehow querying/filtering/modifying the list
// of ids, instead of as taking some kind of action on them.
foreach (var fooId in fooIds)
{
teamService.NotifyFooChanged(fooId);
}
// #2
fooIds.ForEach(fooId => teamService.NotifyFooChanged(fooId));
// #3
fooids.ForEach(teamService.NotifyFooChanged);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment