Check if Object implements an Interface?

  • Thread starter Thread starter Lucas Tam
  • Start date Start date
L

Lucas Tam

Hi all,

I like to dynamically check if an object implements a particular interface.

Currently I am doing:

Ctype(Object, IInterface)

If the object implements the interface it will not throw an error... Is
there a better way I can do this via System.Reflection?

Thanks!
 
If the object implements the interface it will not throw an error... Is
there a better way I can do this via System.Reflection?

Why do you want to use Reflection? The easiest way is

If TypeOf obj is IInterace Then



Mattias
 
Why do you want to use Reflection? The easiest way is

If TypeOf obj is IInterace Then

Oh Ha Ha... I didn't think TypeOf would check it's interfaces... I always
thought TypeOf only checked it's object type : )
 
Back
Top