473,513 Members | 2,562 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Iterate through all the interfaces supported by an object

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...

Dec 16 '05 #1
1 1737
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
"Dave" <dp*@eliassen.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
| 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...
|
Dec 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2298
by: Code4u | last post by:
My colleagues and I have been discussing techniques for implementing interfaces in C++. We're looking for a mechanism similar to COM's QueryInterface, in which a certain types of objects can be queried, at run-time, for a particular interface and if it is supported, a pointer or reference to that interface passed to the caller. Two possible...
2
10748
by: Daniel Faensen | last post by:
As a good OO programmer that I hopefully am I prefer to implement against interfaces rather than classes. This is especially useful when it comes to multiple inheritance which is as you know an issue and not supported in languages as Java or C# - for good reasons. I have an object graph I want to persist using the XML serialization features...
8
700
by: Phil D | last post by:
Hi, I am new to c# and oop and have a question about interfaces which I hope someone can help me with. The book I am using (C# Step by Step) explains how to create and implement interfaces (in terms of syntax and grammar), but what it doesn't cover is why I'd use an interface, and the reasons for doing so. Currently I just can't see...
3
1086
by: Arjang | last post by:
suppose I have an interface reference IA, to an object implementing let's say, InterfaceA. Is it possible to query IA and find out whether some other interface e.g. IntefaceB is also supported? Is it possible to get the list of all the interfaces supported from an InterfaceRefernce and/or from an Object at runtime? if above are...
5
13931
by: dj | last post by:
I know seasoned OOP-savvy developers will roll their eyes at this one, but can anyone provide a clear explanation as to *why* one would need to use an Interface in a VB.NET application? Every book and article I seem to run across jumps right into "and here's how Interfaces are implemented..." followed by a block of meaningless (to me) code...
1
314
by: Dave | last post by:
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...
3
1446
by: Jeff User | last post by:
Hi I want to create a rather simple object with a few string attributes to hold some database user information such as: public class UserInfo { //Basic user information for each user associated with a database. private string sDbName; private string sUserName; .... other stuff....
18
1963
by: _dee | last post by:
Question about best use of interfaces: Say there's a 'Master' class that needs to implement a few interfaces: class Master : I1, I2, I3 { } The actual code already exists in smaller classes that each
18
2372
by: Tony | last post by:
class Interface { public: virtual void DoItNow()=0; }; class A: public Interface { public: void DoItNow(); // satisfies interface explicitly
0
7397
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7565
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7128
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7543
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5704
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5103
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4759
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
1612
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.