Iterate through all the interfaces supported by an object

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

If I have an "object", how can I list all the interfaces that the
object implements? I just want to list the string "names" of the
interfaces...
 
Dave,
You can get Type.GetInterfaces to get the list of Interfaces that the type
implements. You can then use Type.Name to get the name of the interface.

Something like:

Object anObject = ...

Type theType = anObject.GetType();
foreach(Type anInterface in theType.GetInterfaces())
{
Debug.WriteLine(anInterface.Name, "interface");
}


--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


| If I have an "object", how can I list all the interfaces that the
| object implements? I just want to list the string "names" of the
| interfaces...
|
 
Back
Top