Very Simple Example of Interface for fresher

Amatya
Posted by Amatya under C# category on | Points: 40 | Views : 296
Very Simple Example of Interface for fresher

public interface IVehicle
{
string GetName();
}

class Car : IVehicle
{
public string GetName()
{
return "Swift";
}
}

class Program
{
static void Main(string[] args)
{
Car myCar = new Car();

Console.WriteLine(myCar.GetName());
}
}


Similarly you have class of Bikes, Jeep, Tractors etc.
Hope it will help you all
Thanks

Comments or Responses

Login to post response