我试着去作出这样的: 摘要方法与泛型类型
我有点困惑。我想创建一个名为Update(T other)的函数,参数“other”类型是类类型。我认为,在抽象类中实现一个通用接口它将起作用,但它不起作用。 :/
如何获得具有泛型类型参数的抽象方法,并在继承的类中指定该类型?那可能吗?我的方法是否正确?
代码:
public interface IUpdateable<T>
{
void Update(T pOther);
}
public abstract class Instruction_Template : IUpdateable<Instruction_Template>
{
public abstract void Update(??? pOther);
}
public class Work_Instruction_Template : Instruction_Template
{
public void Update(Work_Instruction_Template pOther)
{
//logic...
}
}
谢谢!
糟糕,提供代码示例而不是UML图表会更好吗? ; P –