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 617047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:23:32+00:00 2026-05-13T18:23:32+00:00

I learned C# back in 2006, and recently tried to get back into it.

  • 0

I learned C# back in 2006, and recently tried to get back into it. I have learned then that they added something called LINQ Extensions to C#3.0. Now I am familiar with extension methods, and I’m just pondering the specifics of those related to IEnumerables.

Earlier today, me and one of my colleagues were debating whether or not the following blocks of code were equivalent:

List<int> integers;
IEnumerable<int> subResult = items.Where(i => IsPrime(i));
IEnumerable<int> orderedResult = subResult.OrderBy(i => i);

versus

List<int> integers;
IEnumerable<int> result = items.Where(i => IsPrime(i)).OrderBy(i => i);

He told me the latest was more efficient because the extension used late querying of it’s source. I’m not quite sure I understood what he meant, and I was wondering if he was right.

  • 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-05-13T18:23:32+00:00Added an answer on May 13, 2026 at 6:23 pm

    They’re equivalent. They both use lazy evaluation / late querying.

    What this means is that when the .Where method is called, it doesn’t perform any actual enumeration of the list, it just keeps a reference to it’s input and the condition it’s going to check and stores those references. When the GetEnumerator method is later called on .Where‘s result, .Where kicks into action.

    Same thing with .OrderBy. It doesn’t actually do enumeration of the list until .GetEnumerator is called.

    This stuff can be hard to understand but there’s a few really good ways to learn about it. First is write up a simple example like you have, preferrably split onto multiple lines, with a simple for-each loop to iterate all the items. The debug the code and step through line-by-line. See how the debugger jumps around. It’s very confusing at first, but run through a few times and you’ll understand how lazy evaluation works.

    Jon Skeet also has a wonderful demo for visualizing LINQ.

    https://msmvps.com/blogs/jon_skeet/archive/2008/02/20/visual-linq-watch-query-expressions-as-they-happen.aspx

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

Sidebar

Related Questions

I learned today that NetBeans 6.5 should have an on-the-fly compilation of (single) Java
So I have a server and a client that communicate various data back and
I learned Java in college, and then I was hired by a C# shop
EDIT: Learned that Webmethods actually uses NLST, not LIST, if that matters Our business
I learned some time ago about Decision Trees and Decision tables. I feel that
I learned that by trying to use the tablesorter plug in from jquery the
I've just recently learned C# and am interested in .net but I don't know
Ruby (and the Rails framework) is the first new programming language that I've learned
I learned to use "exists" instead of "in". BAD select * from table where
I learned C++ when it was C with classes. I find myself increasingly disliking

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.