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

  • Home
  • SEARCH
  • 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 46619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:59:39+00:00 2026-05-10T15:59:39+00:00

Inspired by another question asking about the missing Zip function: Why is there no

  • 0

Inspired by another question asking about the missing Zip function:

Why is there no ForEach extension method on the IEnumerable interface? Or anywhere? The only class that gets a ForEach method is List<>. Is there a reason why it’s missing, maybe performance?

  • 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. 2026-05-10T15:59:40+00:00Added an answer on May 10, 2026 at 3:59 pm

    There is already a foreach statement included in the language that does the job most of the time.

    I’d hate to see the following:

    list.ForEach( item => {     item.DoSomething(); } ); 

    Instead of:

    foreach(Item item in list) {      item.DoSomething(); } 

    The latter is clearer and easier to read in most situations, although maybe a bit longer to type.

    However, I must admit I changed my stance on that issue; a ForEach() extension method would indeed be useful in some situations.

    Here are the major differences between the statement and the method:

    • Type checking: foreach is done at runtime, ForEach() is at compile time (Big Plus!)
    • The syntax to call a delegate is indeed much simpler: objects.ForEach(DoSomething);
    • ForEach() could be chained: although evilness/usefulness of such a feature is open to discussion.

    Those are all great points made by many people here and I can see why people are missing the function. I wouldn’t mind Microsoft adding a standard ForEach method in the next framework iteration.

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

Sidebar

Ask A Question

Stats

  • Questions 66k
  • Answers 66k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Sessions are the way to go here, they are intended… May 11, 2026 at 11:25 am
  • added an answer Cheesy google search answer... but it seems to address your… May 11, 2026 at 11:25 am
  • added an answer You're looking for an implementation of markov chains for English… May 11, 2026 at 11:25 am

Related Questions

Inspired by another question asking about the missing Zip function: Why is there no
Inspired by this CodingHorror article, Protecting Your Cookies: HttpOnly How do you set this
Inspired by Raymond Chen's post , say you have a 4x4 two dimensional array,
Inspired by the MVC storefront the latest project I'm working on is using extension
Inspired by this question , I wanted to try my hand at the latest
Inspired by this question and answer , how do I create a generic permutations
Inspired by the question What’s the simplest way to call Http GET url using
Inspired by this question I began wondering why the following examples are all illegal
Inspired by Eric Sink's interview on the stackoverflow podcast I would like to build
This question was inspired by a similar question: How does delete[] know the size

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.