問題:
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