Generic Wishlist for new version of C#
IMHO, Generics are one of the best parts of C# v2.0. Lots of redundant brain dead code can be eliminated by making generic version.
Generic constraints are also a beautiful invention but they fall painfully short in one area, the new constraint. The new constraint is limited in that you can only specify that a type has an empty accessible constructor. My want is that you can specify the types that are a part of that constructor like so.
public class Foo
{
public static T CreationHelper
where T : class, new(int)
{
// Some setup code followed by
return new T(int);
}
}
0 Comments:
Post a Comment
<< Home