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

Related Questions

I'm wondering if it's possible to use a wildcard to select multiple cookies. I'm
is it possible to be able Multiple select files when make browse file? any
Is it possible to dynamically create a select statement with multiple where() clauses? Suppose
I'm using CakePHP 2.0. Is it possible to display multiple fields in select/dropdown box
Possible Duplicate: SQL - how to SELECT multiple tables and JOIN multiple rows from
Is it possible to select multiple elements using an array selector ? If so,
Is it possible to select multiple non-consecutive lines (or sections) in VIM's visual mode?
When working with Oracle is it possible to select multiple columns at once and
Possible Duplicate: select multiple rows from uitableview and delete I am developing an application
i am using contact picker, is it possible to select multiple contacts with the

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.