I found, using this unnatural syntax, it is possible to constrain the type parameters in multiple ways. Like so:
public class MyClass <T, U> : MyBaseClass <T> where T : class where U : AnotherClass, new()
{
public AnotherClass AnotherClass { get; set; }
public MyClass()
{
AnotherClass = new U();
}
//my class
}This works fine and can be very useful at times



0 comments:
Post a Comment