C#: Determining whether a class implements certain interface

typeof(IMyInterface).IsAssignableFrom(myClassInstance.GetType());
typeof(IMyInterface).IsAssignableFrom(typeof(MyClass));

Type.IsAssignableFrom()

Return Value
Type: System.Boolean

true if c and the current Type represent the same type, or if the current Type is in the inheritance hierarchy of c, or if the current Type is an interface that c implements, or if c is a generic type parameter and the current Type represents one of the constraints of c. false if none of these conditions are true, or if c is a null reference.

circle’s Notes: C#: Determining whether a class implements certain interface

Author: admin

3 thoughts on “C#: Determining whether a class implements certain interface

  1. I simply couldn’t leave your website before suggesting that I really loved the standard information a person provide for your visitors?

    Is going to be again steadily to check up on new posts

  2. Pretty section of content. I simply stumbled upon your blog and
    in accession capital to claim that I acquire in fact loved account
    your blog posts. Anyway I’ll be subscribing on your augment and even I achievement you get
    right of entry to constantly fast.

Geef een reactie

Het e-mailadres wordt niet gepubliceerd.