sachin dimbre

sachin dimbre

  • NA
  • 15
  • 18.9k

why need implicit operator while creating child class

Oct 25 2013 1:48 PM
Hello,

Why we need implicit operator while creating child class in c sharp?

I am creating wrapper classes(c#) for the classes supported by one Automation tool.
ex.  something like "public class MyClass : ToolClass" and so on for some other classes also


Concern:
1) Why do I need to add two implicit cast operators and a constructor to the newly created class(MyClass).

                           public static implicit operator MyClass(Element element);
                           public static implicit operator MyClass(string path);

2) As MyClass is child of ToolClass it should call this implicitly (as ToolClass is already doing this.)

Thanks in advance...

Answers (3)