I suggest you ...

New syntax to map interface members to the base class

Explicit interface implementation in VB makes the code much better readable and maintainable than C# code with its implicit (i.e. hidden/secret) interface implementation.
It is one of the main advantages of VB over C#.

However there is one drawback: If a class implements an interface, all interface members have to be implemented directly in that class.
There is no way in VB to map an interface member to a member of the implementing classe's base class.

In C# this works implicitly without any extra code. In VB, of course, we want to maintain an explicit way to achieve it.
A workaround exits in VB, but it involves an extra method call.

Today (explicit call to the base class):
Public Override Sub Foo() Implements IFace.Foo
MyBase.Foo()
End Sub

Future improvement (direct mapping to the base class, no End Sub, Overrides or Shadows allowed):
Public Sub MyBase.Foo() Implements IFace.Foo

Future improvement, alternative with a new keyword:
Public Sub Foo() Implements IFace.Foo MapsToBase

155 votes
Vote
Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
You have left! (?) (thinking…)
Truw shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

4 comments

Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
Submitting...
  • Mark Hurd commented  ·   ·  Flag as inappropriate

    A further extension to the same idea:
    Suppose you had a Partial Class implementing the interface, then it could make sense to have:

    Public Sub MyClass.Bar() Implements IFace.Foo

    BTW I've copied the "Public" from the existing example. I'd guess the best option here would be nothing or Partial to signify Bar must or doesn't have to exist respectively. (I assume the former to be the case.)

  • Jason commented  ·   ·  Flag as inappropriate

    They way interfaces are used in VB is clearly one of the top reasons to prefer VB over C# (which only offers the horror of implicit interface implementation).
    This suggestion would fill a gap in VB's interface system.

Feedback and Knowledge Base