C# syntax: Placing the interface's name in the implementation's declaration

c#, interface, syntax

Solution

When you place a method like this, you're saying that this is the explicit implementation of the interface. You can read a good tutorial on MSDN via that link.

Also, a comparison might be helpful for a full view of what this means.

Problem

I came across some interesting C# syntax that I'm not familiar with in the source code for the Composite Application Library for WPF's `DelegateCommand<T>` class. There are some method declarations which are prefixed with the `ICommand` interface name, and they do not have accessibility modifiers specified. For example: ``` bool ICommand.CanExecute(object parameter) { ... } ``` What is this syntax called and where can I read more about it? I assume there's an implicit `public`, but I can't figure out what the benefit of specifying the class name is. My guess is that it might just be there for organization.

Original source