J-L submitted this idea :
the "is" operator works with both interfaces and (base)classes.
Basically it's "can I treat 'MyObject' as a 'MyInterface'".
A different way would be the "as" operator, which tries a cast but
gives a 'null' if it didn't work:
MyInterface mi = MyObject as MyInterface;
if (mi != null) ...
And if you really want to, you could also use reflection.
Hans Kesting
HI,
>
I don't find the method ro detect if a class implement an interface.
>
I try
>
if (MyObject implements MyInterface)
>
but it doesn't work.
>
if (MyObject is MyInterface)
>
work. Is it the only method to do that ?
>
J-L
>
I don't find the method ro detect if a class implement an interface.
>
I try
>
if (MyObject implements MyInterface)
>
but it doesn't work.
>
if (MyObject is MyInterface)
>
work. Is it the only method to do that ?
>
J-L
Basically it's "can I treat 'MyObject' as a 'MyInterface'".
A different way would be the "as" operator, which tries a cast but
gives a 'null' if it didn't work:
MyInterface mi = MyObject as MyInterface;
if (mi != null) ...
And if you really want to, you could also use reflection.
Hans Kesting