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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:59:12+00:00 2026-05-17T02:59:12+00:00

I’m in the process of learning Interfaces. I’ve been reading through some books/articles and

  • 0

I’m in the process of learning Interfaces. I’ve been reading through some books/articles and so far so good – I’ve written a few sample Interfaces of my own. Yay 🙂

Now, I’ve noticed that one of the most popular C# Interfaces around is the IEnumerable Interface. It’s used quite a lot for all sorts of collections etc..

Anyway, I’d like to examine it, with intent to further understand how it actually works. I’ve searched Google but I can’t seem to find a reference to the actual source code, but I imagine it would contain the Interface itself, and a class(es) containing the various Methods.

So, is anyone able to help?

Much appreciated

  • 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-17T02:59:12+00:00Added an answer on May 17, 2026 at 2:59 am

    IEnumerable is pretty simple:

    [ComVisibleAttribute(True)]
    [GuidAttribute("496B0ABE-CDEE-11d3-88E8-00902754C43A")]
    public interface IEnumerable
    {
        IEnumerator GetEnumerator();
    }
    

    And for completeness, IEnumerator

    [ComVisibleAttribute(true)]
    [GuidAttribute("496B0ABF-CDEE-11d3-88E8-00902754C43A")]
    public interface IEnumerator
    {
        Object Current {get;}
        bool MoveNext();
        void Reset();
    }
    

    But more often what you’re really seeing in code samples is IEnumerable<T>

    public interface IEnumerable<out T> : IEnumerable
    {
        IEnumerator<T> GetEnumerator();
        IEnumerator GetEnumerator(); //inherited from IEnumerable
    }
    

    And again for completeness, IEnumerator<T> (with IDisposable):

    public interface IEnumerator<out T> : IDisposable, IEnumerator
    {
    
        void Dispose(); //inherited from IDsiposable
        Object Current {get;} //inherited from IEnumerator
        T Current {get;}
        bool MoveNext(); //inherited from IEnumerator
        void Reset(); //inherited from IEnumerator
    }
    
    [ComVisibleAttribute(true)]
    public interface IDisposable
    {
        void Dispose();
    }
    

    That’s really all there is to it. There is no direct implementation code for any of this that’s specific to IEnumerable or the related code show here. Rather, types like arrays or List<T> will inherit from IEnumerable and implement the required methods. Everything else beyond that is done via extension methods.

    What makes it all even more powerful are these items:

    1. C#’s foreach keyword supports looping over anything that has a GetEnumerator() method that returns an IEnumerator, and therefore you can use any type that implements IEnumerable with a foreach loop.
    2. The linq query comprehension syntax works in a similar way, such that you can use most any IEnumerable with linq to objects.
    3. The yield keyword allows you to create something called iterator blocks. Iterator blocks have some neat properties (like lazy evaluation) and allow you easily create your own IEnumerable types without having to go to all the trouble of defining a new class first.

    Finally, it’s worth pointing out here that IDisposable is another interface worth further study, as it is used quite a bit in the framework and has direct language support similar to IEnumerable’s foreach with the using keyword.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have thousands of HTML files to process using Groovy/Java and I need to
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6

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.