简体   繁体   English

接口实现它自己的方法

[英]Interface implementing it's own method

We recently came across an interface that looks similar to this in our solution. 我们最近在我们的解决方案中遇到了类似于此的界面。 When we upgraded to VS 2015 it caused build issues. 当我们升级到VS 2015时,它会导致构建问题。 We believe the code is safe to remove, but want to be sure nobody else could think of why this would be valid code, or unsafe code to change (We would remove the implements on all of these)? 我们相信代码可以安全删除,但是要确保没有其他人能想到为什么这将是有效的代码,或者更改不安全的代码(我们会删除所有这些的工具)?

Public Interface IMyInterface
    Property p1 as string Implements IMyInterface.p1
    Property p2 as string Implements IMyInterface.p2
    Property p3 as string Implements IMyInterface.p3
    Property p4 as string Implements IMyInterface.p4
    .
    .
    .
End Interface

Just not sure why or how an interface method can implement a property on itself. 只是不确定接口方法为什么或如何在自身上实现属性。

The Visual Basic reserved word Implements is used in two ways. Visual Basic保留字Implements以两种方式使用。 The Implements statement signifies that a class or structure implements an interface. Implements语句表示类或结构实现接口。 The Implements keyword signifies that a class member or structure member implements a specific interface member. Implements关键字表示类成员或结构成员实现特定的接口成员。

You should remove the Implements IMyInterface.p_ part of the property declarations. 您应该删除属性声明的Implements IMyInterface.p_部分。

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

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