LINQ performance - deferred v/s immediate execution
问题 I have seen that sometimes the performance of LINQ to Objects queries can be improved significantly if they forced to execute immediately by using .ToArray() , but can't quite understand why. For example, in the sample below, the execution of the function Deferred() is much slower than the function Immediate() , and grows exponentially with the value of limit (perhaps it was exponential in both functions, but execution time with Immediate() was too little for me to say definitively). public