Wednesday, May 9, 2007

Inheriting Interfaces

As I'm sure I said earlier, I'm currently going backwards and implementing an Interface on all the custom controls of one of our projects, and implementing even standard controls with this interface, to make things a tad easier to maintain and to shorten the code base a bit.

It was going happily along, until I stumbled across a set of classes one of which inherited from the other.

In C# that's not a problem, I wouldn't have ever even known. But of course, the project is in VB.Net and it threw up compiler errors. Apparently, in VB.Net you can't implement an interface in a class if a base class already implements the interface.

So, disturbed by this glaring problem in the VB.Net design, I went to our friend Google to find an answer. Much to my enjoyment (and almost amazement) Google actually provided an answer to my problem this time, and it was the top search return, so I could have even used the "feeling lucky" button.

Anyways, the return result was this article, entitled 'Re'implementing Interface Implementations: VB.Net vs. C#.

Glee! A solution has been proposed. And apparently it's the simplest solution possible. For VB.Net all one has to do is override the base class's method which implements the Interface's method and it's all good to go.

No comments:

Blog Widget by LinkWithin