C#接口。 隐式实现与显式实现

女生的网名这么多〃 提交于 2020-10-28 09:06:32

问题:

What are the differences in implementing interfaces implicitly and explicitly in C#? 在C#中隐式显式实现接口有何区别?

When should you use implicit and when should you use explicit? 什么时候应该使用隐式,什么时候应该使用显式?

Are there any pros and/or cons to one or the other? 彼此之间是否有优点和/或缺点?


Microsoft's official guidelines (from first edition Framework Design Guidelines ) states that using explicit implementations are not recommended , since it gives the code unexpected behaviour. Microsoft的官方指南(来自第一版Framework Design Guidelines )指出, 不建议使用显式实现 ,因为它会给代码带来意想不到的行为。

I think this guideline is very valid in a pre-IoC-time , when you don't pass things around as interfaces. 我认为,在您未将事物作为接口传递 ,该指南在IoC之前非常有效

Could anyone touch on that aspect as well? 任何人都可以谈谈这方面吗?


解决方案:

参考一: https://stackoom.com/question/bIz/C-接口-隐式实现与显式实现
参考二: https://oldbug.net/q/bIz/C-Interfaces-Implicit-implementation-versus-Explicit-implementation
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!