代码之家  ›  专栏  ›  技术社区  ›  mark vanzuela

VB.NET中的显式接口实现

  •  13
  • mark vanzuela  · 技术社区  · 15 年前

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

    3 回复  |  直到 15 年前
        1
  •  12
  •   daxsorbito    15 年前

    将方法设置为私有。

        2
  •  21
  •   Community    7 年前

    作为 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
    
        3
  •  11
  •   Anton Gogolev    15 年前

    只声明子/函数 Private :

    Private Function Bar() As String Implements IFoo.Bar