C# Interfaces

The purpose of Interfaces in C# is to define a contract. Any class that then implements the interface will know which methods it needs to have. An interface is like an abstract class, but without any implementation.

Let’s look at an example. Let’s say we have a Vehicle interface, like below. A Vehicle will have wheels. If this were an abstract class, we could define the implementation of HowManyWheels, for example. As this is an interface, we are simply saying there is a method HowManyWheels that will need to be implemented: