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

The Archive Base Latest Questions

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

In a question answer I find the following coding tip:- 2) simple lambdas with

  • 0

In a question answer I find the following coding tip:-

2) simple lambdas with one parameter:

x => x.ToString() //simplify so many calls 

As someone who has not yet used 3.0 I don’t really understand this tip but it looks interesting so I would appreciate an expantion on how this simplifies calls with a few examples.

I’ve researched lambdas so I think I know what they do, however I may not fully understand so a little unpacking might also be in order.

  • 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:57:36+00:00Added an answer on May 10, 2026 at 3:57 pm

    When you need to create an instance of a delegate which has a single parameter, lambda expressions allow you to create that delegate ‘inline’ in a very concise manner. For instance, here’s code to find a particular person in a list, by their name:

    List<Person> list = new List<Person>(); // [..] Populate list here Person jon = list.Find(p => p.Name == 'Jon'); 

    In C# 2.0 you could use an anonymous method which was a little bit more longwinded, but not too bad:

    List<Person> list = new List<Person>(); // [..] Populate list here Person jon = list.Find(delegate(Person p) { return p.Name == 'Jon'; }); 

    In C# 1.0 you’d have to create a whole extra method. In addition, if you wanted to parameterise it, you’d have to create a different type, whereas anonymous methods and lambda expressions capture their executing environment (local variables etc) so they act like closures:

    public Person FindByName(List<Person> list, String name) {     return list.Find(p => p.Name == name); // The 'name' variable is captured } 

    There’s more about this in my article about closures.

    While passing delegates into methods isn’t terribly common in C# 2.0 and .NET 2.0, it’s a large part of the basis of LINQ – so you tend to use it a lot in C# 3.0 with .NET 3.5.

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

Sidebar

Ask A Question

Stats

  • Questions 160k
  • Answers 160k
  • 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
  • Editorial Team
    Editorial Team added an answer You're passing in a function where a string is expected.… May 12, 2026 at 11:43 am
  • Editorial Team
    Editorial Team added an answer The problem is using "x.item.@propX" instead of simply "x.@propX" in… May 12, 2026 at 11:43 am
  • Editorial Team
    Editorial Team added an answer In these situations, I generally do one of two things:… May 12, 2026 at 11:43 am

Related Questions

Hi I'm pretty new to Stack Overflow so I hope that I'm doing this
I am trying to modify a list and since my modifications were getting a
Let's take a concrete example and hope I can be clear. Suppose the (ordered)
I enjoy and highly recommend Juval Lowy's - C# Coding Standard . Juval explicitly

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.