4 ms·
I don't know if I misunderstanding you, but you can indeed specify class Something<T> where T : new Check this out: http://msdn.microsoft.com/en-us/library/d5x7
by gjulianm 15y ago
I don't know if I misunderstanding you, but you can indeed specify class Something<T> where T : new
Check this out: http://msdn.microsoft.com/en-us/library/d5x73970.aspx http://msdn.microsoft.com/en-us/library/d5x73970.aspx
And about numerical types, I agree that would be great to have a base class "Number" for double, int, etc. But meanwhile you can use this trick: http://stackoverflow.com/questions/3329576/generic-constraint-to-match-numeric-types http://stackoverflow.com/questions/3329576/generic-constrain...
- noblethrasher 15y agoRight now you can only specify that a type must have a paramerterless public constructor. He or she wants to be a le to specify (presumably) arbitrary constructors (or at least a copy constructor).