Practice mode C#

Which LINQ method forces immediate execution of a query?

Correct answer D. ToList

Explanation

Operators that return a single value or a materialised collection, such as ToList, ToArray, Count, Sum and First, execute the query at once. Where, Select and OrderBy return deferred sequences that run only when enumerated. Calling ToList is useful when you want a snapshot of the results or need to avoid running an expensive query more than once.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.