简体   繁体   English

VB.NET中的显式接口实现

[英]Explicit interface implementation in VB.NET

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

As others have said , make the routine private, and it forces clients to call through the interfaces. 正如其他所说 ,将例程设为私有,这会强制客户端通过接口进行调用。

Just one more word. 再说一个字。 Explicit interface implementation in C# also allows the programmer to inherit two interfaces that share the same member names and give each interface member a separate implementation . C#中的显式接口实现还允许程序员继承共享相同成员名称的两个接口,并为每个接口成员提供单独的实现 In VB.Net, that's easy, because the implementing methods can have different names from the interface names. 在VB.Net中,这很容易,因为实现方法的名称可以与接口名称不同。

Function ICanUseAnyNameILike() As String Implements IFoo.Bar

Function ItsTotalAnarchy() As String Implements IFoo2.Bar, IFoo3.ItsMadnessReally

将该方法设为私有。

只需声明子/功能Private

Private Function Bar() As String Implements IFoo.Bar

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM