473,756 Members | 2,721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Find with Reflection the interfaces a class implements

Hello,

Can anyone please help me with this matter.
I try to find the interfaces implemented by a class using
Reflection.

e.g:
public class A : InterfaceB, InterfaceC

how can I get (the info about) the "custom" interfaces InterfaceB
and InterfaceC ?

Thank you,
Cezar
Nov 15 '05 #1
3 1695
Cezar <ce*********@po lymtl.ca> wrote:
Can anyone please help me with this matter.
I try to find the interfaces implemented by a class using
Reflection.

e.g:
public class A : InterfaceB, InterfaceC

how can I get (the info about) the "custom" interfaces InterfaceB
and InterfaceC ?


Look at Type.GetInterfa ces.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #2
> Look at Type.GetInterfa ces.

Thanks again Jon for your reply.

I was using Type's IsInterface before... and I don't know yet why
it didn't return everything.

I have another question:

If my class implements another class, what should I use ? I didn't
see a GetBaseClass or something ...

public class MyClass : MyBaseClass

Cezar
Nov 15 '05 #3
Cezar <ce*********@po lymtl.ca> wrote:
Look at Type.GetInterfa ces.


Thanks again Jon for your reply.

I was using Type's IsInterface before... and I don't know yet why
it didn't return everything.

I have another question:

If my class implements another class, what should I use ? I didn't
see a GetBaseClass or something ...

public class MyClass : MyBaseClass


The Type.BaseType property does what you want.

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

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

Similar topics

12
2371
by: Antony | last post by:
Hello - I am wanting to print out a "Yes" next to classes that implement "Interface01", otherwise a "No". Here is my code. It crashes with a null reference exception and I am not sure why. Ideas? Thank you for you help. Tony Imports System.Reflection Public Class Form1
8
292
by: Rlrcstr | last post by:
If I have some code behind a form and I want to be able to pass an object to it... any of several user defined classes that I have... and then display the values in the member variables of the class, I'm guessing that I use Reflection. I have never used anything like that before. Can someone point me to a good example of doing this? I will basically be drawing a table on the form with dta from the passed class in columns. The...
5
13944
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 without explaining why this is being used in the first place. e.g. Why not use a Class object? ...
1
2304
by: John F | last post by:
Hello All, I'm dynamically loading a form through reflection. I have this working. What I'd like to do is implement an interface so that I can cast my instance to that interface. I want to be able to call methods and pass parameters normally in the dynamically loaded Form. Yesterday Nicholas Paldino's suggested this. Btw, thanks Nick! As hard as I tried without asking further questions, I need a little more help. :)
27
3859
by: jm | last post by:
I am having trouble understanding the purposes of an interface, even though the concept of interfaces is around me all the time (user interface, for example). I'm just not understanding software interfaces. Like anything else, it appears Interfaces are by design something that requires documentation. I know this may be obvious, but if I have a class A and I say, well, class A implements IMyInterface. The fact that it implements...
2
1283
by: RSH | last post by:
I am trying really hard to grasp the concept of Interfaces and their real world usage. I constructed a simple project of a webpage that contains two controls. I am enabling communication back and forth between the page as well as controls. I used two interfaces to remove the hardcoded references. Is what I'm doing correct? Any suggestions? Thanks!
5
1588
by: Random | last post by:
How can I use reflection (or some other method) to find the type of an object that has been passed in to my method under an interface definition? I try to use GetType, but that won't work.
5
1863
by: | last post by:
I am having problems with casting or converting a class to to an interface from which it derives. I'm certain that it's due to how it's being loaded, but I'm not sure how to get past the problem. Here's a general outline of the architecture. It's oversimplified, but I think it's enough info to help: Assembly A.dll { interface IMyBase {}
1
1622
by: Big Daddy | last post by:
I have an interface called PeriodicJob. In a DLL, I declare the interface and then create a class that implements the interface. In a different executable, I also declare the interface. I then load the assembly with late binding and create an instance of the class with reflection. I try to cast the object to the class type of the interfact, but I get an invalid cast exception. It says that the object I am creating isn't a PeriodicJob. ...
0
9456
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
9275
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
10034
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
9872
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
9843
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
9713
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...
1
7248
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3358
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.