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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:26:17+00:00 2026-05-15T20:26:17+00:00

Is it possible to select multiple entiies in ForEach Extension Method? (i.e) partial code

  • 0

Is it possible to select multiple entiies in ForEach Extension Method?

(i.e)

partial code is given

DataTableA.AsEnumerable().ToList().
    ForEach(x=>
    {
        x.SetField<string>("Name","Jon Skeet"),
        x.SetField<string>("msg","welcome")
    });

when i apply multiple selection in ForEach

 x=>
{
    x.SetField<string>("Name","Jon Skeet"),
    x.SetField<string>("msg","welcome")
}

I am unable to complete the statement.Help Please.

  • 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-15T20:26:18+00:00Added an answer on May 15, 2026 at 8:26 pm

    You need to make the lambda compile to valid C#:

    DataTableA.AsEnumerable().ToList().ForEach(
         x=>  
         {
             x.SetField<string>("Name","Jon Skeet");
             x.SetField<string>("msg","welcome");
          });
    

    That being said, I’d caution against this. Using ForEach is purposely causing side-effects, and it’s really not more concise than the foreach statement in the language itself. Personally, I’d just write:

    foreach(var element in DataTableA.AsEnumerable())
    {
        element.SetField<string>("Name","Jon Skeet");
        element.SetField<string>("msg","welcome");
    }
    

    This, in my opinion, is much more clear than the first statement (and shorter, and more efficient, since it doesn’t force a full enumeration into the list, and a second enumeration of the list elements).

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer mymod and mdir.mymod are considered different modules - here's somewhat… May 16, 2026 at 2:06 pm
  • Editorial Team
    Editorial Team added an answer Let me see if I understand you: you want an… May 16, 2026 at 2:06 pm
  • Editorial Team
    Editorial Team added an answer Pardon if I do not understand you clearly, but in… May 16, 2026 at 2:06 pm

Trending Tags

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

Top Members

Related Questions

Is it possible to select, say, every fourth element in a set of elements?
i have this code where you can select the date you like to attend
Possible Duplicate: How does Facebook Sharer select Images? When I attach a link on
Say I have a structure like: class SomeObject Public Name as String Public Created
I am currently extending yii-s admin extension, yiiadmin. What would be the easiest way
I want to map 127.0.0.1 to multiple names instead of the standard way as
Before looking into my question, lets consider the fopen in C. There are multiple
I am looking for an answer to a specific problem of fetching whole LINQ
I have three tables, table one (tableA) containing users data like name and email,
This one seems painfully obvious to me, but for some reason I can't get

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.