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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:23:36+00:00 2026-05-14T08:23:36+00:00

Just a thought. Wouldn’t it be useful to have optional type parameters in C#?

  • 0

Just a thought.

Wouldn’t it be useful to have optional type parameters in C#?

This would make life simpler. I’m tired of having multiple classes with the same name, but different type parameters. Also VS doesn’t support this very vell (file names) 🙂

This would for example eliminate the need for a non-generic IEnumerable:

interface IEnumerable<out T=object>{
  IEnumerator<T> GetEnumerator()
}

What do you think?

  • 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-14T08:23:36+00:00Added an answer on May 14, 2026 at 8:23 am

    I am definitely for it.

    I’m currently writing helper methods for different scenarios where I want to pass references to different members and methods of classes. To accomplish this I’m taking, for example, an Expression<Func<TIn, TOut>> as argument to the helper (that lets me reach the method with a lambda expression, thus keeping everything strongly typed).

    BUT – I currently need to define a new helper method for each different number of input arguments, since I need to have a different amount of generic arguments to it. Instead of

    HelperMethod<TIn>(Expression<Action<TIn>> arg) // Yes, C# can distinguish
    HelperMethod<TOut>(Expression<Func<TOut>> arg) // these two from eachother
    HelperMethod<TIn, TOut>(Expression<Func<TIn, TOut>> arg)
    HelperMethod<TIn1, TIn2, TOut>(Expression<Func<TIn1, TIn2, TOut>> arg)
    // etc
    

    I could make do with, at the most, two methods:

    HelperMethod<TIn>(Expression<Action<TIn>> arg)
    HelperMethod<TOut, TIn1 = DummyType, ...>(Expression<Func<TIn1, ..., TOut> arg)
    

    In my case, it would avoid a lot of code duplication…

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

Sidebar

Related Questions

Just listening to this week's podcast and thought it would be nice to group
Just a thought, but would using an IFRAME over a DIV essentially make that
I thought that to clone a List you would just call: List<int> cloneList =
OK thought I understood IDipose but just reading the best practices section of Accelerated
I've just started experimenting with SDL in C++, and I thought checking for memory
I have seen the GUID Collisons discussions but just wanted your thoughts on whether
I just wanted to see if I could have your thoughts on the design
I've just solved another *I-though-I-was-using-this-version-of-a-library-but-apparently-my-app-server-has-already-loaded-an-older-version-of-this-library-*issue (sigh). Does anybody know a good way to verify
Ordinarily I wouldn't just post an error message on SO, but after a Google
INITIAL NOTE: This is just for a personal tinkering project; I'm not writing enterprise

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.