Whenever we have common methods, Events...etc need to be
supported by multiple classes then we can use Interfaces. In C#, single class
can implement multiple interfaces.
We need to follow below coding rules while using Interfaces
in C#.
• Interfaces name should start with
the letter “I”
• Name Interfaces with adjective
phrases. Don't use nouns or noun phrases.
Most of the instances we don't require to use Interfaces,
instead we can use abstract classes which can have method implementation whereas
interfaces can contain only method declarations. And the other reason why to
use abstract classes wherever it is possible is classes can be versioned
whereas interfaces cannot.
Below are the specific reasons when we must use Interfaces.
• When multiple unrelated classes
want to support same protocol
• When the classes have already
established base classes. Eg: User Interface controls, XML Web services
• Where aggregation is not
appropriate or practical
Once assemblies implement interfaces, it's usually
impossible to change later.