クラスAのメソッドがあります
public IList<T> MyMethod<T>() where T:AObject
このメソッドを別のジェネリッククラスBで呼び出したい。このTには制約がない。
public mehtodInClassB(){
if (typeof(AObject)==typeof(T))
{
//Compile error here, how can I cast the T to a AObject Type
//Get the MyMethod data
A a = new A();
a.MyMethod<T>();
}
}
クラスCはクラスAObjectから継承されます。
B<C> b = new B<C>();
b.mehtodInClassB()
何かご意見は?
ursが思い出させた後...更新:
はい。私が実際にやりたいのは
typeof(AObject).IsAssignableFrom(typeof(T))
いいえ
typeof(AObject)==typeof(T))