Archive for the ‘lambda expression’ tag
Evolution of looping
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.