C#接口。 隐式实现与显式实现 - C# Interfaces. Implicit implementation versus Explicit implementation

问题:

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

When should you use implicit and when should you use explicit? 何时应该使用隐式,何时应该使用显式? ui

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


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 )指出, 不建议使用显式实现 ,由于它会给代码带来意想不到的行为。 spa

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

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


解决方案:

参考一: https://stackoom.com/question/bIz/C-接口-隐式实现与显式实现
参考二: https://oldbug.net/q/bIz/C-Interfaces-Implicit-implementation-versus-Explicit-implementation
相关文章
相关标签/搜索