473,805 Members | 1,981 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question about interfaces

Is there an easy way to find out what classes implement a given interface?
For example, it might be useful to know what classes implement ICollectible.

Much obliged,
Geoff.
Jul 21 '05 #1
5 1433
If TypeOf myCollection Is ICollectible Then
' myCollection implements ICollectible
End If

If GetType(ICollec tible).IsAssign ableFrom(myColl ection.GetType) Then
'again, myCollection implements ICollectible
End If

In C#, I believe you can use the typeof keyword to get the type of an
object.

Also, You can use the Type.GetInterfa ces method to get a collection of type
objects for all the interfaces implemented by an object. You can also use
the Type.GetInterfa ce method to get an interface by name.

hope that helps..
Imran.
"Geoff Pennington" <Ge*******@veri zon.netNoSpam> wrote in message
news:ev******** ******@TK2MSFTN GP14.phx.gbl...
Is there an easy way to find out what classes implement a given interface?
For example, it might be useful to know what classes implement ICollectible.
Much obliged,
Geoff.

Jul 21 '05 #2
Geoff Pennington <Ge*******@veri zon.netNoSpam> wrote:
Is there an easy way to find out what classes implement a given interface?
For example, it might be useful to know what classes implement ICollectible.


Again, MSDN is your friend. Go to the overview page for the interface,
and it lists the classes which implement it directly.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #3
If I understand correctly, you are answering the opposite question from the
one I asked. Your reply seems to address the question "What interfaces does
this class implement?", but what I want to know is "What classes implement
this interface?".

Sometimes, when choosing a class for a specific purpose, I want to be sure I
have considered all the options.

Geoff.

"Imran Koradia" <no****@microso ft.com> wrote in message
news:ek******** ******@TK2MSFTN GP10.phx.gbl...
If TypeOf myCollection Is ICollectible Then
' myCollection implements ICollectible
End If

If GetType(ICollec tible).IsAssign ableFrom(myColl ection.GetType) Then
'again, myCollection implements ICollectible
End If

In C#, I believe you can use the typeof keyword to get the type of an
object.

Also, You can use the Type.GetInterfa ces method to get a collection of type objects for all the interfaces implemented by an object. You can also use
the Type.GetInterfa ce method to get an interface by name.

hope that helps..
Imran.
"Geoff Pennington" <Ge*******@veri zon.netNoSpam> wrote in message
news:ev******** ******@TK2MSFTN GP14.phx.gbl...
Is there an easy way to find out what classes implement a given interface? For example, it might be useful to know what classes implement

ICollectible.

Much obliged,
Geoff.


Jul 21 '05 #4
OK, good. Thanks.

"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
Geoff Pennington <Ge*******@veri zon.netNoSpam> wrote:
Is there an easy way to find out what classes implement a given interface? For example, it might be useful to know what classes implement
ICollectible.
Again, MSDN is your friend. Go to the overview page for the interface,
and it lists the classes which implement it directly.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Jul 21 '05 #5

"Geoff Pennington" <Ge*******@veri zon.netNoSpam> wrote in message
news:e6******** ******@TK2MSFTN GP09.phx.gbl...
If I understand correctly, you are answering the opposite question from the one I asked. Your reply seems to address the question "What interfaces does this class implement?", but what I want to know is "What classes implement
this interface?".


My apologies. I misread your question. However, there's no way through code
to figure out what classes implement a given interface. If you are talking
about classes and interfaces in the .NET class library, you can look up the
MSDN documentation for the given interface - it'll have a list of classes
that directly implement the interface.

hope that helps..
Imran.
Jul 21 '05 #6

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

Similar topics

44
4293
by: lester | last post by:
a pre-beginner's question: what is the pros and cons of .net, compared to ++ I am wondering what can I get if I continue to learn C# after I have learned C --> C++ --> C# ?? I think there must be many know the answer here. thanks
44
1948
by: lester | last post by:
a pre-beginner's question: what is the pros and cons of .net, compared to ++ I am wondering what can I get if I continue to learn C# after I have learned C --> C++ --> C# ?? I think there must be many know the answer here. thanks
7
1226
by: tshad | last post by:
I am trying to understand why I would use interfaces. In the following example for IPrinciple, I have the following code: ************************************************************ using System; using System.Collections; using System.Security; using System.Security.Principal;
1
1725
by: Larry | last post by:
I checked definition of class CollectionBase public abstract class CollectionBase : IList, ICollection, IEnumerable, it implements 3 interface IList, ICollection and IEnumerable. I found IList is derived or extended from ICollection and IEnumerable. Why the definition of class CollectionBase just implement IList interface which has functions of ICollection and IEnumerable?
1
1111
by: brianlanning | last post by:
I have a class that represents a business object. Currently, this class exists as a vb6 "class" which will be ported to .net. The plan is to separate this out into a .net object residing in a web service, then replace the vb6 class with a different vb6 class which is just a proxy that calls the web service through a COM wrapper, then back to the original vb6 class through interop (don't ask). For now, everything will just pass through. ...
0
9716
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10609
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10360
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10366
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10105
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9185
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6876
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3845
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.