泛型类是基类,并且成员方法使用泛型数据类型,您将如何使派生的方法接受整数而不是泛型数据类型?
你可以做这样的事情-
public class MyBaseClass<T>
{
public virtual void MyMethod(T typeT)
{
//some important functionality
}
}
public class MyChildClass : MyBaseClass<int>
{
public override void MyMethod(int typeInt)
{
//Do your stuff
//and if you would like to call base method, use the following-
base.MyMethod(typevar);
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句