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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:50:45+00:00 2026-06-12T00:50:45+00:00

As per this link :http://msdn.microsoft.com/en-us/library/bb397906.aspx namespace Linq { class IntroToLINQ { static void Main()

  • 0

As per this link :http://msdn.microsoft.com/en-us/library/bb397906.aspx

namespace Linq
{
    class IntroToLINQ
    {
        static void Main()
        {
            // The Three Parts of a LINQ Query: 
            //  1. Data source. 
            int[] numbers = new int[7] { 0, 1, 2, 3, 4, 5, 6 };

            // 2. Query creation. 
            // numQuery is an IEnumerable<int> 
            var numQuery =
                from num in numbers
                where (num % 2) == 0
                select num;

            // 3. Query execution. 
            foreach (int num in numQuery)
            {
                Console.Write("{0,1} ", num);
            }
        }
    }

}

It states that query will not be exeucted , until data is iterated through foreach. But when I debugged , the data memeber of var(resultviews) contains the result values before the execution of foreach. Why this is happening?

  • 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-12T00:50:46+00:00Added an answer on June 12, 2026 at 12:50 am

    Because your debugger is executing the query for you.

    Linq is using something that is called Deferred Execution. Here is a good blog post that explains it: LINQ and Deferred Execution.

    When you first execute the iterator, the query is processed and executed (in memory, to a database or in another way). Your debugger will do this for you.

    Take for example the following code (you can paste this in a Console Application):

    using System;
    using System.Diagnostics;
    using System.Linq;
    
    namespace Stackoverflow
    {
        class Program
        {
            static void Main()
            {
                var numbers = Enumerable.Range(0, 100).ToList();
    
                var filteredNumbers = from n in numbers
                                      where n > 50
                                      select n;
    
                Debugger.Break();
    
                foreach(int f in filteredNumbers)
                {
                    Console.WriteLine(f);
                }
    
            }
        }
    }
    

    When you look at filteredNumbers on the Debugger.Break() statement you will see the following:

    Debug view of Linq Enumerable

    The Results View options has the Value: “Expanding the Results View will enumerate the IEnumerable”. And that’s what’s happening in the Debugger.

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

Sidebar

Related Questions

As per this link we can add node in app.confi file. http://msdn.microsoft.com/en-us/library/ff602939.aspx so, where
As per http://msdn.microsoft.com/en-us/library/h21twfw7(v=VS.100).aspx (for Visual Studio 2010) strstreambuf is deprecated. I was of the
I've taken the most basic example of setting up a hosted endpoint ... http://msdn.microsoft.com/en-us/library/ms731758.aspx
So I followed the instructions per this link http://www.opencart.com/index.php?route=documentation/documentation&path=32_35_60 but my paypal account is
I recently ran the database repair tool as per this link: http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/db-repair-tool At the
I have built a service with ServiceStack (customer example) as per this link: https://docs.google.com/present/view?id=dg3mcfb_213gsvvmmfk
I'm following the directions here: http://social.msdn.microsoft.com/forums/en-US/adodotnetentityframework/thread/0ce70e04-0ba0-4819-8898-87243203adb9/ to support mapping to a view that uses
As per this MSDN article: W3C Extended Log File Format (IIS 6.0) It says
i am looking at this site: http://cloudexchange.cloudapp.net/stackoverflow/s/84/rising-stars-top-50-users-ordered-on-rep-per-day set nocount on DECLARE @endDate date SELECT
Let's say I have a URL: http://example.com/person/list This website will display a list of

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.