Does LINQ cache computed values?
问题 Suppose I have the following code: var X = XElement.Parse (@" <ROOT> <MUL v='2' /> <MUL v='3' /> </ROOT> "); Enumerable.Range (1, 100) .Select (s => X.Elements () .Select (t => Int32.Parse (t.Attribute ("v").Value)) .Aggregate (s, (t, u) => t * u) ) .ToList () .ForEach (s => Console.WriteLine (s)); What is the .NET runtime actually doing here? Is it parsing and converting the attributes to integers each of the 100 times, or is it smart enough to figure out that it should cache the parsed