Say I have two interfaces, IFeaturesA, IFeaturesB.
IFeaturesA has a set of signature methods. Let's say one is:-
public void printMe();
IFeaturesB implements IFeaturesA, and adds a new signature method, such as:-
public void printMeAlso();
Say I want to use a generic method, such as:-
public Check<E>(E passedItem)
{
}
If i passed in IFeaturesA, I want to be able to call the methods of this. If i pass in IFeaturesB, I want to be able to call the extra method, printMeAlso();
What is the best way to check for an interface type passed into a generic method and access its methods in C#? Is checking for the object type against the two interface types and then casting to the type the optimal way?