Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8965277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:46:25+00:00 2026-06-15T16:46:25+00:00

How does the extension method ToList() work? Say I have an IEnumerable of 10000

  • 0

How does the extension method ToList() work? Say I have an IEnumerable of 10000 items. Will ToList() create a new List and iterate over the IEnumerable of 10000 items and then return me a List or does .NET do it in some other way?

This MSDN link talks about immediate execution of a DB query. My question is only about converting IEnumerable to a List.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:46:26+00:00Added an answer on June 15, 2026 at 4:46 pm

    It doesn’t necessarily iterate, although that’s the “worst case” scenario. Basically it calls new List<T>(source), but that has some tricks up its sleeve: if the source implements ICollection<T>, the constructor can call ICollection<T>.CopyTo() to copy the complete data into an array. This may well be implemented more efficiently than single-stepping iteration. Likewise in the ICollection<T> case, the new list knows the final size to start with, so it won’t need to keep expanding its internal buffers.

    For a few more details, see my Edulinq ToList() blog post.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

why linq's except extension method does not have Except<TSource> Method (IEnumerable<TSource>,HashSet<TSource>) overload? for example
Update: This does work, I was being stupid :( i have the following extension
I have the following extension method public static class ListExtensions { public static IEnumerable<T>
HashSet does not have an AddRange method, so I want to write an extension
I have this extension method: public static bool In<T>(this T source, params T[] list)
I have extension method that does something like this public static void DoStuff(this ObjectContext
I am trying to implement an extension method that will work with linq2entities. I
CS1928: 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'DropDownList' and the best extension method
I have List<Attributes> la = new List<Attributes>(); la = (from t in result let
I'm trying to write an extension method that will add the function HasFactor to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.