VB.NET中的显式接口实现

时间:2009-10-16 09:48:05

标签: .net vb.net

如何在VB.NET中实现显式接口实现?

3 个答案:

答案 0 :(得分:21)

由于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

答案 1 :(得分:12)

将该方法设为私有。

答案 2 :(得分:11)

只需声明子/函数Private

Private Function Bar() As String Implements IFoo.Bar