Interfaces with real life examples An interface is a programming structure/syntax that allows the computer to enforce certain properties on an object (class). For example, say we have a car class and a tricyclic class and a truck class. Each of these three classes should have a start engine() action. How the "engine is started" for each vehicle is left to each particular class, but the fact that they must have a start engine action is the domain of the interface. The syntax of an Interface We can implement single interface or multiple interfaces to the class. By default interfaces are public. We declare interface by using "interface" keyword. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CsharpnaijaInterfaceTutorial { interface IEngine { void Start(); }...
Csharp Naija is a blog that teaches C# programming using a practical guide. C# Nigeria is here to guide interested individual to the world of software Engineering.