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 ...

Get Application Development Using Visual Basic® and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.