Thanks Richard,
but what i was really after, is that only by using an interface refernce
only. for example Let MyObj implement InrefaceA.
MyObj o= new MyObj();
IntrefaceA h;
h=(InterfaceA)o;
now if I pass h to a method only accepting InterfaceA, e.g.
public MethodA( IntrfaceA IntfA )
{
//need to find out wether object passes as intfA supports InterfaceB
if (IntfA is InterfaceB) //does this work??
{
// do something using interfaceB
}
}
In Delphi I can use QueryInterface to check and convert from one interface
to another.
"Richard A. Lowe" <ch*****@yumspamyumYahoo.com> wrote in message
news:eS**************@TK2MSFTNGP12.phx.gbl...
If you want to know if any interface is supported you can just use the C#
'is' operator, i.e.
Object o = // create somthing here
if(o is IMyInterface)
{
// whatever
}
Getting all interfaces is a matter of using reflection:
Type[] interfacesIImplement = o.GetType().GetInterfaces();
--
C#, .NET and Complex Adaptive Systems:
http://blogs.geekdojo.net/Richard
"Arjang" <Ar****************@NotTheRealPart.zorg> wrote in message
news:uc**************@TK2MSFTNGP14.phx.gbl... 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 possible then how to do it in C#?
TIA