<p>What are the differences in implementing interfaces <strong>implicitly</strong> and <strong>explicitly</strong> in C#?</p>

<p>When should you use implicit and when should you use explicit?</p>

<p>Are there any pros and/or cons to one or the other?</p>

<hr>

<p>Microsoft's official guidelines (from first edition <a href="https://rads.stackoverflow.com/amzn/click/com/0321246756" rel="noreferrer" rel="nofollow noreferrer">Framework Design Guidelines</a>) states that <strong>using explicit implementations are not recommended</strong>, since it gives the code unexpected behaviour.</p>

<p>I think this guideline is very <strong>valid in a pre-IoC-time</strong>, when you don't pass things around as interfaces.</p>

<p>Could anyone touch on that aspect as well?</p>

Implicit
is when you define your interface via a member on your class.
Explicit
is when you define methods within your class on the interface. I know that sounds confusing but here is what I mean:
```
IList.CopyTo
```
would be implicitly implemented as:
```
```
public void CopyTo(Array array, int index)
{
    throw new NotImplementedException();
}
```
```
and explicitly as:
```
```
void ICollection.CopyTo(Array array, int index)
{
    throw new NotImplementedException();
}
```
```
The difference is that implicit implementation allows you to access the interface through the class you created by casting the interface as that class and as the interface itself. Explicit implementation allows you to access the interface only by casting it as the interface itself.
```
```
MyClass myClass = new MyClass(); // Declared as concrete class
myclass.CopyTo //invalid with explicit
((IList)myClass).CopyTo //valid with explicit.
```
```
I use explicit primarily to keep the implementation clean, or when I need two implementations. Regardless, I rarely use it.
I am sure there are more reasons to use/not use explicit that others will post.
See the
next post
in this thread for excellent reasoning behind each.