9.1 Rules
Rules within C# that must be followed when it comes to interfaces
An interface can only define the properties and method signatures. It does not do any implementation. We define what properties and methods the class should follow.
Classes inherited from interfaces must honor the property and method signatures. They are promises between the two saying that they will have what the interface wants.
Many classes can inherit from a particular interface.
An interface may inherit from multiple base interfaces.
A class may implement-inherit from multiple interfaces.
A C# class may only inherit from one class.
Example
Discussion
If you have written out this code in Visual Studio, try commenting out one of the methods or properties by typing //
in front of the lines. You should get an error from visual studio saying you have not fulfilled all the promises of the interface.
Next: Code Intent
Last updated