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 : )
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top