O'Reilly logo

Application Development Using Visual Basic® and .NET by Dana L. Wyatt, Peter Thorsteinson, Robert J. Oberg

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Resolving Ambiguity in Interfaces

When working with interfaces, an ambiguity can arise if a class implements two interfaces and each has a method with the same name and signature. As an example, consider the following versions of the interfaces IAccount and IStatement. Each interface contains the method Show.

Interface IAccount
   Sub Deposit(ByVal amount As Decimal)
   Sub Withdraw(ByVal amount As Decimal)
   ReadOnly Property Balance() As Decimal
   Sub Show()
End Interface

Interface IStatement
   ReadOnly Property Transactions() As Integer
   Sub Show()
End Interface

How can a class that implements both of these interfaces specify implementations for both of the Show methods that have the same name? The answer is to use an alias for each of the method implementations ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required