class A { }
interface I { }
void GenericStuff<T>(T x) { }
void SpecificStuff<T>(T x) where T : A, I { }
void Start<T>(T x)
{
if (x is A && x is I)
SpecificStuff(x); // <---- Wrong type
else
GenericStuff(x);
}
I've got the situation illustrated above. In method Start()
I get a single parameter x
and depending on it's type I want to call either the GenericStuff()
or the SpecificStuff()
method. Naturally, the type constraints prevent me from doing so, and since there are two of them, I cannot get around them by casting.
Is there any way (short of reflection) to accomplish this?