【发布时间】:2009-10-16 09:48:05
【问题描述】:
如何在VB.NET中实现显式接口实现?
【问题讨论】:
如何在VB.NET中实现显式接口实现?
【问题讨论】:
由于others 拥有said,因此将例程设为私有,它会强制客户端通过接口调用。
再多说一句。 C# 中的显式接口实现还允许程序员inherit two interfaces that share the same member names and give each interface member a separate implementation。在 VB.Net 中,这很容易,因为实现方法的名称可以与接口名称不同。
Function ICanUseAnyNameILike() As String Implements IFoo.Bar
Function ItsTotalAnarchy() As String Implements IFoo2.Bar, IFoo3.ItsMadnessReally
【讨论】:
IFoo3.ItsMadnessReally 作为接口方法。
将方法设为私有。
【讨论】:
只需声明子/函数Private:
Private Function Bar() As String Implements IFoo.Bar
【讨论】: