I have the following c# classes:
class A : Object
{
foo() {}
}
class B : Object
{
foo() {}
}
I want to write a generic method that applies to both:
void bar<T>(T t)
{
t.foo();
}
this does not compile complaining the foo() is not a member of T. I can add a constraint for T to derive from one of the classes:
void bar<T>(T t) where T : A
but how can I have it for both?