Implementation of interface when using child class of a parent class in method of interface

Posted by dotnetdev on Stack Overflow See other posts from Stack Overflow or by dotnetdev
Published on 2010-04-06T21:36:58Z Indexed on 2010/04/06 21:43 UTC
Read the original article Hit count: 160

Filed under:

I don't have access to my dev environment, but when I write the below:

interface IExample
 void Test (HtmlControl ctrl);



 class Example : IExample
 {
     public void Test (HtmlTextArea area) { }

I get an error stating the methods in the class implementation don't match the interface - so this is not possible. HtmlTextArea is a child class of HtmlControl, is there no way this is possible? I tried with .NET 3.5, but .NET 4.0 may be different (I am interested in any solution with either framework).

Thanks

© Stack Overflow or respective owner

Related posts about c#