I have a method in Class A
public IList<T> MyMethod<T>() where T:AObject
I want to invoke this method in another generic class B. This T is without any constraints.
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>();
}
}
Class C is inherited from Class AObject.
B<C> b = new B<C>();
b.mehtodInClassB()
any thoughts?
After urs reminding...Update:
Yes. What I actually want to do is
typeof(AObject).IsAssignableFrom(typeof(T))
not
typeof(AObject)==typeof(T))