Re: implement

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hans Kesting

    Re: implement

    J-L submitted this idea :
    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
    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


Working...