How to call a generic method with type constraints when the parameter doesn't have these constraints?
问题 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