How to determine if an object has a certain method

D

Don

Is it possible to determine if an object has a certain method or property
available? For example, say I have a function with one parameter of type
Object. At the end of the function I want to properly clean up the object
passed to me, but I want to know, first, if the object that was passed to me
implements a Dispose method or not. Is there a way to tell?

- Don
 
H

Herfried K. Wagner [MVP]

* "Don said:
Is it possible to determine if an object has a certain method or property
available? For example, say I have a function with one parameter of type
Object. At the end of the function I want to properly clean up the object

\\\
Dim f As Form1 = Me
.... = f.GetType().GetMethod(...)
///
passed to me, but I want to know, first, if the object that was passed to me
implements a Dispose method or not. Is there a way to tell?

\\\
If TypeOf x Is IDisposable Then
...
End If
///
 

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

Top