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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:29:30+00:00 2026-05-27T14:29:30+00:00

Below is how far I made it. I need to send Expression<Func<T, string>> as

  • 0

Below is how far I made it. I need to send Expression<Func<T, string>> as the parameter instead of Func<T,string> to the Get function, and still have Select() work. Is this easily possible? This is formatted for LinqPad.

void Main()
{
    // Setup sample data in wholelist
    var wholelist = new List<Example>();
    for (var a = 0; a < 10; a++)
    {   var t = new Example { id = a.ToString(), name = a.ToString() };
        wholelist.Add(t);
    }

    // Do the real work
    var names = Get<Example>( wholelist, p => p.name );
    // LinqPad shows content
    names.Dump();
}

public class Example
{
    public string id {get;set;}
    public string name {get;set;}
}

public static List<string> 
    Get<T>(IEnumerable<T> source, Func<T, string> selector)
{    
    var list = source.Select<T,string>(selector).ToList();
    return list;
}

The why is because we have a lot of functions already calling this one with Expression<Func<T,string>>.

  • 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-27T14:29:31+00:00Added an answer on May 27, 2026 at 2:29 pm

    Have you tried expression.Compile?

    public static List<string> Get<T>(IEnumerable<T> source, Expression<Func<T, string>> selector)
    {
        var list = source.Select<T, string>(selector.Compile()).ToList();
        return list;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So far i have got the code below which works lovely when trying an
Below is my current char* to hex string function. I wrote it as an
I have a List(Of MyObject) that I need to sort. So I've made sure
Below I have a very simple example of what I'm trying to do. I
I have been looking at the YouTube Insight function and want to learn how
This is the well know select algorithm. see http://en.wikipedia.org/wiki/Selection_algorithm . I need it to
I am learning Python and so far I can tell the things below about
I have been looking for a easy way to add borders to custom made
I have an issue with this jquery code below. Please give me advice or
Below is the code so far that I am working on, It will be

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.