Suppose I have a class like
interface ISampleInterface
{
void SampleMethod();
}
class ImplementationClass : ISampleInterface
{
// Explicit interface member implementation:
void ISampleInterface.SampleMethod()
{
// Method implementation.
}
static void Main()
{
// Declare an interface instance.
ISampleInterface obj = new ImplementationClass();
// Call the member.
obj.SampleMethod();
}
}
From the main method how could I determine that the ImplementationClass class implements ISampleInterface before writing the code like below
SampleInterface obj = new ImplementationClass();
obj.SampleMethod();
is there any way….please discuss. thanks.
You could use reflection: