The overriding method cannot change the inherited constraints.
using System; public class MyClass { public virtual void MethodA<T>(T arg) where T : new() { } } public class YClass : MyClass { public override void MethodA<T>(T arg) { T obj = new T(); } }
1. | A simple generic class hierarchy | ||
2. | A derived class with its own type parameters | ||
3. | A non-generic class can be the base class of a generic derived class | ||
4. | Overriding a virtual method in a generic class |