Head.SmackOnTable();

Contains Nuts.

Evolution of looping

without comments

While im writing a new project using vs.net 2008, Resharper cropped up a nice helper, saying I should use a lambda expression on my code, which made me think about how looping has evolved…


for (int i = 0; i < all.Count; i++)
{
tagCount.Add(new TagCount(container[i].Count, container[i]));
}

foreach (Tag tag in container)
{
tagCount.Add(new TagCount(tag.Count, tag));
}

container.ForEach(delegate(Tag tag)
{
tagCount.Add(new TagCount(container.Count, tag));
});

container.ForEach(tag => tagCount.
Add(new TagCount(container.Count, tag)));

Iv always thought lambda’s were gimmicky, but I do have to admit, they do look fancy and makes things like what im doing easier.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • DotNetKicks
  • DZone

Written by Monty

November 17th, 2008 at 4:36 pm

Posted in .NET,Misc

Tagged with , ,

Leave a Reply