Search code examples
c#reflectioninterface

Test if object implements interface


What is the simplest way of testing if an object implements a given interface in C#? (Answer to this question in Java)


Solution

  • if (object is IBlah)
    

    or

    IBlah myTest = originalObject as IBlah
    
    if (myTest != null)