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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:35:27+00:00 2026-05-23T10:35:27+00:00

The generic Func<> and Action<> delegates from later versions of .NET are very appealing,

  • 0

The generic Func<> and Action<> delegates from later versions of .NET are very appealing, and it’s been demonstrated in many places that these can easily be recreated in code targeting .NET 2.0, such as here.

From the perspective of a library targeting .NET 2.0 however, which may be consumed by applications built against any higher version of .NET, how does this stack up. Is implementing this “compatibility layer” within the library absolutely a recipe for conflict (both in terms of private and public interface), or are there ways to make this work independent of the target framework that the consuming application builds against?

If this is a non-starter, would it be better to either:
A) Define an identical set of parametrized delegates with different names? or..
B) Stick strictly with .NET 2.0 convention, and define new delegate types as I need them?

  • 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-23T10:35:27+00:00Added an answer on May 23, 2026 at 10:35 am

    The plain truth is that Func<> and Action<> are a good idea. They make your code much easier to read and they avoid a shocking amount of messy boilerplate delegate declarations. That’s why you want to use them.

    So you have this really appealing programming style you want to use, it’s a standard technique that is now used almost universally instead of the old way, but you can’t use it because you are targeting a legacy version of the framework. What should you do?

    You have three choices:

    1. Use the programming style that was in common use before the feature
    2. Add the feature to your own code in spirit but with non-conflicting names
    3. Add the feature to your own code with the “real” names but in your own namespace

    Using the old programming style gives up all the benefits that we have come to appreciate from the feature. That’s a big sacrifice. But maybe all your co-developers are used to this style of programming.

    Using the feature with non-conflicting names seems sensible enough. People will be able to read the code and benefit from the features, but no-one will be confused that they appear to be something that they’re not. When you are finally ready to upgrade, you’ll have to patch up the names. Luckily Ctrl+R, Ctrl+R makes doing that very easy.

    Using the feature with the same names as the standard feature means your code can target an older version but appear to be using newer features. Seems like a win/win. But this could cause confusion and you have to be careful that your types aren’t exposed to other unknowing assemblies, possibly causing source level compilation problems. So you have to be careful and be perfectly clear about what is happening. But it can work effectively.

    You have to pick whatever approach makes sense in your situation depending on your needs. There is no one right answer for everybody, only trade-offs.

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

Sidebar

Related Questions

I have a semi generic class that receives a Func<> from another class to
Here's a snippet of code from within TurboGears 1.0.6: [dispatch.generic(MultiorderGenericFunction)] def run_with_transaction(func, *args, **kw):
C# has generic function types such as Action<T> or Func<T,U,V,...> With the advent of
I have a generic method that accepts a Func<int> and I would like to
When I pass call a Generic Method that return A Func and pass in
it does not look like there is support for the Action and Func delegates
Iv'e created a generic handler (.ashx) to handle some simple input from some dropdowns
I have a generic script that creates a Gnuplot macro. Is there a way
I have a generic class that should allow any type, primitive or otherwise. The
I've got a generic<> function that takes a linq query ('items') and enumerates through

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.