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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:59:34+00:00 2026-05-23T19:59:34+00:00

When using LINQ extension methods like Enumerable.Select, is it better to use a Lambda

  • 0

When using LINQ extension methods like Enumerable.Select, is it better to use a Lambda expression, or a regular method?

I’m asking this both with respect to (memory) optimization*, and to readability**.

Example code:

private void Main() {
    var array = new int[1];
    var result1 = array.Select(x => x.ToString());  // Lambda
    var result2 = array.Select(LinqHelper);  // method
}

private string LinqHelper(int x) {
    return x.ToString();
}

*I’m mostly thinking of closures creating scopes with unused instantiated variables in them, simply because those variables were in scope when the Lambda was created. Edit – this was stupid thinking, since variables are only captured by a closure when they’re referenced in the Lambda expression.
**Both options look OK to me.

  • 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-23T19:59:35+00:00Added an answer on May 23, 2026 at 7:59 pm

    From an optimization point of view, there should be no difference.

    From a readability point of view, I’d think about whether you need the same logic in several places. If so, use a method and use a method group conversion. That way you don’t repeat yourself, so you don’t have to change several bits of code if your requirements change.

    If you’re only using the logic in a single place and it’s short, a lambda expression captures the logic “inline” in a way which is usually easier to read IMO.

    I typically avoid long lambda expressions, with the possible exception of use with TPL, e.g.

    Parallel.ForEach(..., x => {
       // I'm quite happy to have a long-ish lambda here - it's like a foreach
       // loop body, basically.
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to use a DataGridViewRowCollection in a LINQ expression using extension methods and
I am having some issues with using the OrderBy extension method on a LINQ
I've written this very simple function to replace a file extension using LINQ in
I am getting this error when I use the Linq expression of var emp
I have a Linq extension method to dynamically filter Linq queries using string values.
Using extension syntax I'm trying to create a left-join using LINQ on two lists
Using LINQ to Entities sounds like a great way to query against a database
Using LINQ to SQL db.Products.Where(c => c.ID == 1).Skip(1).Take(1).ToList(); executes SELECT [t1].[ID], [t1].[CategoryID], [t1].[Name],
I am using LINQ to query a generic dictionary and then use the result
I've created a simple extension method on the string type: public static bool Contains(this

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.