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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:34:09+00:00 2026-06-09T12:34:09+00:00

I have this query string[] names = { Tom, Dick, Harry, Mary, Jay };

  • 0

I have this query

string[] names = { "Tom", "Dick", "Harry", "Mary", "Jay" };

var query =
    from     n in names
    where    n.Contains ("a")   // Filter elements
    orderby  n.Length           // Sort elements
    select   n.ToUpper();       // Translate each element (project)

foreach(var item in query)
    Console.WriteLine(item);

works perfectly, gives the result JAY MARY HARRY as expected.

But when I run this

string[] names = { "Tom", "Dick", "Harry", "Mary", "Jay" };

var query2 = names.Where(n=> n.Contains("a")).OrderBy(n=>n.Length).Select(n=>n.ToUpper);

foreach(var item in query2)
    Console.WriteLine(item);

I get this message The type arguments for method 'System.Linq.Enumerable.Select<TSource,TResult>(System.Collections.Generic.IEnumerable<TSource>, System.Func<TSource,TResult>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

I tried running this too

var query2 = names.Where(n=> n.Contains("a")).OrderBy(n=>n.Length).Select<string, string>(n=>n.ToUpper);

It says Cannot convert method group 'ToUpper' to non-delegate type 'string'. Did you intend to invoke the method? Cannot convert lambda expression to delegate type 'System.Func<string,string>' because some of the return types in the block are not implicitly convertible to the delegate return type.

I don’t know what’s happening? Can any one tell me why the query syntax is working fine method syntax is not working?

  • 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-09T12:34:10+00:00Added an answer on June 9, 2026 at 12:34 pm

    You are missing a pair of parentheses after ToUpper:

    var query2 = names
        .Where(n=> n.Contains("a"))
        .OrderBy(n=>n.Length)
        .Select(n=>n.ToUpper() /* <<== HERE */);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm always confusing about this stuff. I have this query : string[] names =
I have a query string that contains a variable like this $field_name = 'features';
I have a url of a type where query string is like this... ?
If I have a query like this: String Category = HttpContext.Current.Request.QueryString[Product].ToString(); IQueryable<ItemFile> pressReleases =
I have this query... SELECT Distinct([TargetAttributeID]) FROM (SELECT distinct att1.intAttributeID as [TargetAttributeID] FROM AST_tblAttributes
I followed this tutorial http://www.tugberkugurlu.com/archive/api-key-authorization-through-query-string-in-asp-net-web-api-authorizationfilterattribute to create custom Authorization filter. I have CarController with
I'm trying to rewrite some query strings I have in my URL like this
Have this query: SELECT HOUR( DATE ) AS hr, COUNT( * ) AS cnt
I have this query which on executing in my sql command line client executes
I have this table where columns correspond to names: i.e. 11 = first, 12

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.