This is, by default, not possible. However, if you know the name of the method you want to invoke, and you are positive that every LinkedItem
type will contain this method, you can use reflection to reach your goal. Note: there's often a better way than resolving to reflection for general programming tasks.
The following will always output true
for DoSomething
. It invokes a static member that's always available (I removed your generic type constraint, as that's not important with static methods).
public class MyList<LinkedItem> : List<LinkedItem>
{
public bool DoSomething()
{
Type t = typeof(LinkedItem);
object o = new Object();
var result = t.InvokeMember("ReferenceEquals",
BindingFlags.InvokeMethod |
BindingFlags.Public |
BindingFlags.Static,
null,
null, new[] { o, o });
return (result as bool?).Value;
}
}
// call it like this:
MyList<string> ml = new MyList<string>();
bool value = ml.DoSomething(); // true
PS: meanwhile, while I typed this, others seem to suggest the same approach ;-)