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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:39:16+00:00 2026-05-11T19:39:16+00:00

Are the following Lambda and Linq expressions equivalent in terms of execution paths? I

  • 0

Are the following Lambda and Linq expressions equivalent in terms of execution paths? I guess I’m wondering if the Linq is going to run differently because it’s going to create an IEnumerable before determining if the enumeration has anything in it whereas the lambda expression will stop on the first digit it finds.

var x = valueToMatch
    .Any(c => Char.IsDigit(c));

var y = (from c in valueToMatch
         select c).Any(c => Char.IsDigit(c)); here

Thx! Joel

  • 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-11T19:39:16+00:00Added an answer on May 11, 2026 at 7:39 pm

    It will run differently, but not in any considerable way. If you use the MSIL Disassembler you will see a slightly different output for the first expression and the second, even with optimizations turned on. You can also look at it using a Reflector (which is a little easier to read).

    The second version will basically pass each element through something like:

    [CompilerGenerated]
    private static char <Match2>b__2(char c)
    {
        return c;
    }
    

    before it executes the Any(c => Char.IsDigit(c)) expression. So there is indeed a difference.

    however, the difference is very small in my opinion.
    Testing a list of 10,000 characters being looped over 10,000,000 with each method the first one clocks in around ~125ms while the second method takes ~185ms.

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

Sidebar

Related Questions

How do I formulate the following in LINQ with LAMBDA expressions. Given (for simplicity
Can the following loop be implemented using IQueryable, IEnumerable or lambda expressions with linq
In my repository implementation I can run the following query using a lambda expression:
I am looking at better way of writing following code using linq/lambda expression.. I
I'm trying to do a JOIN in Linq using lambda expressions ... and running
Is is possible to convert following into a simpler more readable linq or lambda
How do I convert the following SQL statement into Lambda Expression or Linq Query?
How do you do Linq with non-lambda express for the following (which does not
I was wondering if there is an easy way to place two Lambda expressions
I have the following lambda function: f = lambda x: x == None and

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.