I don't know if this is what you are looking for, but the following code shows where 
an interface's method is declared:

using System;
using System.Reflection;

interface I
{
        void Foo();
}

class A : I
{
        public void Foo() {}
}

class B : A {}

class C : B {}

class InterfaceReflection
{
        static void Main(string[] args)
        {
                Type t = typeof(C);
                MethodInfo mi = t.GetMethod("Foo");
                Console.WriteLine("{0} is declared in {1}",
                        mi.ToString(),
                        mi.DeclaringType.FullName);
        }
}

Hope this help.


Emilio D'Angelo

-----Mensaje original-----
De: Thomas Tomiczek [mailto:[EMAIL PROTECTED] 
Enviado el: mi�rcoles, 25 de junio de 2003 15:45
Para: [EMAIL PROTECTED]
Asunto: [ADVANCED-DOTNET] Type class - finding out whether a specific interface is 
iplemented in the type on THIS inheritance level...

Possible?

 

I have an inheritance hierarchy like this:

 

As, implements I

A

Bs, implements I

B

Cs, implements I

C

 

Given a Type T, is there any way for me to find out whether the given
type has the implements clause explicitly given? Means, is As, Bs or Cs?

 

Or is I available everywhere starting from As down and this information
is not accessible anymore?

 

Regards

 

Thomas Tomiczek

THONA Consulting Ltd.

(Microsoft MVP C#/.NET)

Reply via email to