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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:27:15+00:00 2026-06-04T12:27:15+00:00

I am wondering why would C# provide the lambda expression if it is a

  • 0

I am wondering why would C# provide the lambda expression if it is a performance killer?

Trying to run the following:

Stopwatch sw = new Stopwatch();
 sw.Start();
 x = x.Select((int i) => i += 1).ToArray();
 sw.Stop();
 Console.WriteLine(sw.ElapsedTicks);

AND

Stopwatch sw = new Stopwatch();
sw.Start();
for (int j = 0; j < 1000; j++) y[j] += 1;
sw.Stop();
Console.WriteLine(sw.ElapsedTicks);

for x = 1000, we would find huge difference.

Is there an appropriate use case for lambda?

  • 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-06-04T12:27:16+00:00Added an answer on June 4, 2026 at 12:27 pm

    I think we must remember LINQ is a language for QUERIES. of course, you can do other stuff with it, as well, such as updating a collection (a how to do asked very often on SO) or running a loop, but why would you do this? LINQ and lambda expressions are not a new, total replacment of procedural programming, its merely a tool which can be used when suitable.

    As other query languages (such as t-sql), LINQ provides you the tools to define WHAT you want to get, and not HOW you want to get it, which also allows you to create a language – independant queries, that you can later parse to whatever you want. It may be very convinient and generic to use in many cases, and also can abstract the underlying data types/data sources, but it also means you leave the concrete implementation of HOW to get whay you asked for to whoever wrote the parser for your queries.

    I suggest you read about some sample linq providers out there. Take a look at LINQ to LDAP for example: such providers allow you, as a develoepr, to concentrate only on the data you want, and not on the underlying data structure/Active Directory API, which can be pretty annoying to use.

    As with every other tool you get, you need to ask yourself what you want to get, and if this tool is the best way to go. A good analogy would be using loops in sql servre query; Of course, it can be done, but you will usually prefer to build a select which will let the sql engine to decide HOW to execute your query.

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

Sidebar

Related Questions

I have run a few using batch jobs, but, I am wondering what would
I'm wondering how i would go about making the following application: a user signs
I was wondering if anyone would help with the following: I have a date
I was wondering if anyone would be able to provide me with some guidance
I provide a web service to my organisation. i was wondering would anyone recommeding
I am trying to learn lambda in C# 3, and wondering how this function
I was wondering would I still need to use a basic game loop for
i was wondering what would be the best way to code a browser plugin
I was just wondering which would be cheaper, using a try catch block for
I am wondering how would I deal with a call to a function when

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.