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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:45:14+00:00 2026-05-28T06:45:14+00:00

I had a query regarding how parameter types in a lambda expression are evaluated.

  • 0

I had a query regarding how parameter types in a lambda expression are evaluated.

If we’re querying an IEnumerable of type Customer and have a statement such as customers.Where(c => c.City == “London”), c is of type Customer.

In HTML Helpers used in ASP.NET MVC 3 if we have a statement like Html.TextBoxFor(c => c.Foo) in a strongly typed view, c is of type that the view is bound to.

What I don’t understand is how the compiler and visual studio intellisense know the type of the parameters in the lambda. The MSDN documentation says “the compiler can infer the type based on the lambda body, the underlying delegate type, and other factors as described in the C# Language Specification”. However I don’t get how the lambda body or the delegate type allow the compiler to determine what the data type of the parameter is.

Cheers,

  • 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-28T06:45:14+00:00Added an answer on May 28, 2026 at 6:45 am

    If you look at the type of Html.TextBoxFor etc. you’ll find the parameter1 isn’t Func<TModel, TProperty> (a compiled delegate), but Expression<Func<TModel, TProperty>> which is actually a data structure from which a delegate can be compiled at runtime.

    Or directly examined to see what it is doing. In this case to ensure that it is actually a field or property access expression, and then reading the name of the property to allow HTML to reference the name, before then getting a delegate to get the property’s value.


    1 As an extension method, the first parameter is the type it applies to, and the second declared parameter is the first parameter when declared.

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

Sidebar

Related Questions

I'm trying to optimize query performance and have had to resort to using optimizer
As I had written in title, I have SQL query, run on Oracle DB,
I had a certain query regarding a question I was asked earlier. I was
A while ago I had a query that I ran quite a lot for
yesterday you had taught me to query record history within a time range here
Problem: I originally had a query that was working great but I'm now having
I am trying to read an XML file using LINQ. I have had no
Folks, I had another issue now regarding to libmysqlclient-dev api Here the story: I
I'm trying to optimize a SQL query with MySQL 5.5, regarding 2 separates requests.
I have had a breakdown on my webhost. Now finally it is up again,

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.