To use such great function as ConvertAll(), I have to convert IList to List, it’s painful.
To use such great function as ConvertAll() , I have to convert IList to
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Note that
List<>is an implementation ofIList<>with actual storage, i.e. it holds an array in the background. In general, anIList<>can be a proxy to something else. In db4o and linq to sql, yourIList<>could ‘point to a query’, i.e. accessing the list will trigger a database operation.This way, you can perform
myList.Skip(600).Take(20);to perform pagination and only in this step will the actual query be executed. AList<>containing a million entries will be huge, while there may beIList<>s that have a hugeCount, but don’t eat a significant amount of memory – as long as you don’t access the elements.ConvertAllwill require each and every object be instantiated so it is a costly operation. Thus, it is better to make the operation explicit and force you to retrieve a specific implementation of the interface. Obviously, conversion requires all objects to be instantiated anyway, so there’s no benefit in doing it lazily.