You can use dynamic
. While this is more or less glorified reflection, it looks much nicer:
void Start<T>(T x)
{
if (x is A && x is I)
SpecificStuff((dynamic)x);
else
GenericStuff(x);
}
Please note:
If, at a later point, you change the type constraints of SpecificStuff
to contain a third interface and you forget to update your if
accordingly, you will get runtime exceptions and not compile time errors.