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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:14:31+00:00 2026-05-19T02:14:31+00:00

So one of my classes implements IQueryable for which it need the GetEnumerator method

  • 0

So one of my classes implements IQueryable for which it need the GetEnumerator method and the code looks like this:

        public IEnumerator<T> GetEnumerator() 
        {
             this.ParseExpression(this.expression);
             return this.GetResults()

        }

        private IEnumerator<T> GetResults() 
        {
              //Processes the expression tree.

              T t = Activator.CreateInstance(typeof(T));
              yield return T;
        }

The weird part is when the control enters first method it skips to the end of it (the closing curly bracket before it enters the GetResults() method. Does this mean that the GetResults() method is executed on a different thread implicitly by the compiler due to the fact that the class implements IEnumerable?

  • 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-19T02:14:32+00:00Added an answer on May 19, 2026 at 2:14 am

    No, it means that there is more code added by the compiler, that you don’t see executed as there is no source code representing it.

    When you use yield, the compiler creates the implementation of an enumerator for you. Calling GetResults doesn’t really call your method, instead it calls the constructor of that enumerator. It’s when you start reading from the enumerator that your method is being called for the first time.

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

Sidebar

Related Questions

Put them all in one separate folder structure or along with classes which implements
I have one interface IMyInterface. A set of classes that implements this interface :
I have two very simple classes, one extends the other: public class LocationType implements
I have two classes one of which inherits from the other. Im trying to
I need to validate a certain property to one of my classes. When I
I have this class class Validator implements iValidation{ protected $_fields, $_errors; public function __construct($fields){
I'm implementing Cloneable with one of my classes, and I need to make a
So I have different layouts for this one Activity. And I have different classes
I have a package with different classes. One class implements a structure data. I
Consider the following two classes public class ServerDAOHb implements Serializable { .... @OneToMany(cascade =

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.