LINQ to Objects – Enumerable.ToList and similiars optimization

February 4, 2009

Update: The post was lost by accident, I added it again. I’ve used the reflector a couple of times to check whether the Enumerable class which provide all the IEnumerable extensions utilizes things taking the actual type into mind. Let’s examine the extension method “Count” - I liked what they did here. They first try and cast it to ICollection, if it passed they simply return the count property. Otherwise they would do what you would do – iterate over the collection and return the iteration counter. I was thrilled to see that...
tags: ,
one comment