I have a problem which I could solve using something like this
sortedElements.ForEach((XElement el) => PrintXElementName(el,i++));
And this means that I have in ForEach a lambda which permits using parameters like int i.
I like that way of doing it, but i read somewhere that anonymous methods and delegates with lambda leads to a lot of memory leaks because each time when lambda is executed something is instantiated but is not released. Something like that.
Could you please tell me if this is true in this situation and if it is why?