What are good reasons to use explicit interface implementation for the sole purpose of hiding members?

Posted by Nathanus on Programmers See other posts from Programmers or by Nathanus
Published on 2011-04-20T20:50:59Z Indexed on 2014/06/07 3:46 UTC
Read the original article Hit count: 317

Filed under:
|
|

During one of my studies into the intricacies of C#, I came across an interesting passage concerning explicit interface implementation.

While this syntax is quite helpful when you need to resolve name clashes, you can use explicit interface implementation simply to hide more "advanced" members from the object level.

The difference between allowing the use of object.method() or requiring the casting of ((Interface)object).method() seems like mean-spirited obfuscation to my inexperienced eyes. The text noted that this will hide the method from Intellisense at the object level, but why would you want to do that if it was not necessary to avoid name conflicts?

© Programmers or respective owner

Related posts about c#

Related posts about design