...

/

Implementing Interfaces

Implementing Interfaces

Learn to create and implement interfaces.

We'll cover the following...

Overview

Let’s see interfaces in action by jumping into the code. We have the ElectricCar class that simulates an electric car. Run the code to see what this class can do.

Press + to interact
Program.cs
ElectricCar.cs
using System;
namespace Interfaces
{
class Program
{
static void Main(string[] args)
{
var car = new ElectricCar();
Console.WriteLine("We've got a Tesla.");
Console.WriteLine("Attempting to drive it.");
car.Drive();
car.StartTheCar(15);
car.StartTheCar(14);
car.Drive();
car.TurnTheCarOff();
}
}
}

Our car can be started, ...

Access this course and 1400+ top-rated courses and projects.