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?
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
I could make do with, at the most, two methods:
In my case, it would avoid a lot of code duplication…