This question and Eric Lippert’s answer got me wondering: How do you decide whether to use an explicit or implicit implementation when implementing methods of an interface?
This question and Eric Lippert’s answer got me wondering: How do you decide whether
Share
(personally) I only see a need for explicit implementations when there is a clash between methods with the same signature.
For example, when implementing
IEnumerable<T>, you should implement 2 methodsGetEnumerator()which have the same signature, except for the return type. So you’ll have to implementIEnumerable.GetEnumerator()explicitly:Another use for an explicit implementation is if you don’t want the method to be called through an object instance, but only through an interface. I personally think this doesn’t make much sense, but in some very rare cases, it can be useful.