0
我有一個抽象類,如下:如何在where語句後添加額外的泛型參數?
class BaseReturnType { }
class DerivedReturnType : BaseReturnType { }
abstract class BaseClass<T> where T : BaseReturnType
{
public abstract T PolymorphicMethod();
}
class DerivedClass : BaseClass<DerivedReturnType>
{
public override DerivedReturnType PolymorphicMethod()
{
return new DerivedReturnType();
}
}
所以,如果添加EXTA parrameter爲通用名爲T2我怎麼把爲Extrac制約對此有何看法?
abstract class BaseClass<T, **T2**> where T : BaseReturnType ???
{
public abstract T PolymorphicMethod();
}
更容易在http://msdn.microsoft.com/en-us/library/d5x73970.aspx的「約束多個參數」部分找到 – outis 2009-11-05 03:49:11