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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:05:50+00:00 2026-05-17T16:05:50+00:00

I see language features like C#’s foreach loop (which requires the use of IEnumerable

  • 0

I see language features like C#’s foreach loop (which requires the use of IEnumerable), and its using syntax (which uses IDisposable, knowing which method to call), and LINQ (which I assume uses a heap of .NET stuff too). All of this seems very tied-in to the .NET framework. So:

  • Could C# exist with a different framework? (Does it already?)
  • If so, how does a language specify “foreach loops require an IEnumerable instance” without tying it in to a framework.
  • 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-17T16:05:51+00:00Added an answer on May 17, 2026 at 4:05 pm

    The best place to investigate this is the C# language specification.
    For example, in the case of enumerables, here are some snippets from the spec:

    10.14.2 Enumerable interfaces

    The enumerable interfaces are the
    non-generic interface
    System.Collections.IEnumerable and all
    instantiations of the generic
    interface
    System.Collections.Generic.IEnumerable.
    For the sake of brevity, in this
    chapter these interfaces are
    referenced as IEnumerable and
    IEnumerable, respectively.

    …

    10.14.5.1 The GetEnumerator method

    An enumerable object provides an
    implementation of the GetEnumerator
    methods of the IEnumerable and
    IEnumerable interfaces. The two
    GetEnumerator methods share a common
    implementation that acquires and
    returns an available enumerator
    object. The enumerator object is
    initialized with the argument values
    and instance value saved when the
    enumerable object was initialized, but
    otherwise the enumerator object
    functions as described in §10.14.4.

    This ties in nicely with how these interfaces are actually defined in the .NET BCL, although it would be completely possible for a different (i.e. non-.NET) framework to provide a similar, compatible implementation that a C# compiler could then target.

    Portions of the spec that are hard to separate from the .NET framework are normally marked with:

    Note: This section is applicable only to the Microsoft .NET implementation of C#.

    On another note,foreachdoesn’t actually requireIEnumerable; it can use a sort of ‘duck-typing’, which you can read about in section 8.8.4 of the spec.

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

Sidebar

Related Questions

Are there any performance penalties when I use multiple nested structures/classes (kinda like using
I'd like to experiment with a popular HTML templating language to see if I
friends, i dont see serbain language in android phone language settings.... i am using
In a language where both are available, would you prefer to see an instance
Since PHP is a dynamic language what's the best way of checking to see
I'm trying to add multi-language support to an OpenSocial application. I see that I
Why don't we see C-like languages that allow for callables with polymorphism in the
See: Understanding Pointers In many C flavoured languages, and some older languages like Fortran,
See title. By lightweight markup I mean something like markdown or wikitext.
I started using LINQ (Language Integrated Query) when it was still in beta, more

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.