Just a quick question for people who know the internal workings of .Net better than me :: -). I ONLY DO that I understand something.
As I see it, when you run LINQ in foreach, the LINQ enumerator is computed (run), it returns a collection, and foreach in this collection. But ... still, I'm not sure:
foreach (VCCTreeItem ti in (from treeItems in TreeItems select treeItems))
Does the LINQ statement (execute) repeat in every loop? I would think (and hope) that NO. However, when performing operations on the collection in, foreachyou receive error messages at run time if the collection is modified. It made me believe that something suspicious could be happening backstage. I never had time to parse / check this out in detail, so I ask you about it. I am sure that some of you know the answer from above: - D.
Oh, and I think I can ask the same question:
foreach (VCCTreeItem ti in TreeItems)
If TreeItems is a property in which getI perform some operations, the property will be evaluated, returned as a value, and foreach will work with that value.
Axonn source
share