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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:18:03+00:00 2026-05-26T16:18:03+00:00

I have a project that is using a generic list of a custom class.

  • 0

I have a project that is using a generic list of a custom class. I have this bound to a grid and I am trying to implement sorting on it. (which is working).

I want to clean my code so I don’t have to do a check for “asc” and “desc” then call either Orderby or OrderByDescending. I would rather set a delegate method at the to of the function and just call OrderMethod, which would already be set to the proper OrderBy… Method.

I can’t seem to get it working.

Here is the delegate that I’ve created. (The class is called ‘FollowingInfo’).

private delegate IOrderedEnumerable<FollowingInfo> OrderMethodDelegate<TSource, TKey>(IEnumerable<FollowingInfo> source, Func<FollowingInfo, string> keySelector);

I’m try to set it as such.

OrderMethodDelegate OrderMethod = FollowList.OrderBy;

But it’s not working…in this example FollowList is of type List(FollowingInfo).

The OrderBy method is an extension method of the generic list class and is defined in Enumerable as such.

public static IOrderedEnumerable<TSource> OrderBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector);

Any ideas of where I’ve gone wrong?

  • 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-26T16:18:03+00:00Added an answer on May 26, 2026 at 4:18 pm

    Define it as:

    private delegate IOrderedEnumerable<TSource> Func<TSource, TKey>(IEnumerable<TSource> source, Func<TSource, TKey> keySelector);
    

    You cannot simply override generic method defined in IEnumerable<T> with replacing TSource parameter. It doesn’t know about FollowingInfo class. You can provide your own OrderBy extension method for IEnumerable<FollowingInfo> and use that kind of delegate in it.

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

Sidebar

Related Questions

I have a Website project that I'm trying to debug using Fiddler. Fiddler doesn't
I have this sample MVC project using jQuery grid. There is only one problem
In a proof-of-concept project I'm working on, I have a generic abstract class that
I have a Java project that I build using an Ant script. I am
I have an existing project that builds fine using my IDE. I'd like to
So, I have Flex project that loads a Module using the ModuleManager - not
In visual studio, I have an asp.net 3.5 project that is using MS Enterprise
I have a website project that I want to build using CruiseControl.net. On one
We have a python project that we want to start testing using buildbot. Its
I have a small command line utility project that I'm using Maven to manage.

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.