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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:07:17+00:00 2026-05-11T09:07:17+00:00

I am trying to understand LINQ and become confident at using it. What I

  • 0

I am trying to understand LINQ and become confident at using it. What I am struggling with are the parameters asked for. Example:

var sortedWords = words.OrderBy(a=>a.Length) 

words is an array collection. OrderBy‘s intellisense says:

Func<string, TKey> keyselector 

A func executes a method, and a string is the value, TKey a key.

In the example http://msdn.microsoft.com/en-us/vcsharp/aa336756.aspx#thenBySimple (ThenBy – Comparer), we compare length by saying a => a.Length. I understand that syntax, but how is that related to what the intellisense is asking for?

I tend to find the method signature and intellisense unreadable because of all the generics.

Thanks.

  • 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-11T09:07:18+00:00Added an answer on May 11, 2026 at 9:07 am
    a => a.Length 

    I understand that syntax, but how is that related to what the intellisense is asking for?

    This chunk of code is a lambda expression. A lambda expression is a handy way of generating an Anonymous method (in this case), or a System.Linq.Expressions.Expression . Let’s break it down by parts.

    • The most noticeable feature is the =>, which seperates parameters from a method body.
    • On the left side of the =>, there is a symbol: a. This is the declaration of a parameter for our anonymous method. The compiler is aware that we are calling OrderBy(), and that OrderBy requires a Func<string, object>. The parameter for such a function is a string, so the compiler determines that a must be a string. The only thing the programmer needed to provide is a name.
    • On the right side of the =>, there is method body. Since this is a one-liner, the return keyword is implied. The IDE provides intellisense against a as a string, which allows you to use the Length property.

    Now, consider this C# 2.0 …

    IEnumerable<string> sortedWords =    Enumerable.OrderBy(words, delegate(string a) {return a.Length;}); 

    With the C# 3.0

    IEnumerable<string> sortedWords = words   .OrderBy(a => a.Length); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand more about linq, for example, if I want to
I'm trying to parse an xml file using LINQ, but as I understand the
I am trying to understand dynamic linq and expression trees. Very basically trying to
I'm trying to understand how to rewrite a join query in LINQ. SELECT cs.qid,cs.qk
I am not a pro on Linq but trying to understand. How to write
So I'm trying to understand IQueryable<T> . A tutorial I'm reading suggests using it
I'm trying to understand some fundamental best practices using Entity Framework. My EDM design
I am trying to understand dynamic linq as used by Scott Guthrie in this
I'm trying to understand why Linq is generating the SQL that it is for
I'm currently trying to understand some of the fundamentals with LINQ. I have been

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.