In C ++ templates, you can indicate that a parameter of a certain type is the default value. That is, if not explicitly specified, it will use type T.
Can this be done or come closer to C #?
I am looking for something like:
public class MyTemplate<T1, T2=string> {}
So, an instance of a type that does not explicitly indicate T2 :
MyTemplate<int> t = new MyTemplate<int>();
It would be essential:
MyTemplate<int, string> t = new MyTemplate<int, string>();
Ultimately, I consider the case when there is a template that is pretty widely used, but I am considering expanding with an additional type parameter. I could subclass, I think, but I was curious if there were any other options in this vein.
generics c # types parameters default
el2iot2 Apr 01 '09 at 23:51 2009-04-01 23:51
source share