interface implementation of functionality in c# code example
Example 1: creating interface in C#
using System;
namespace Grepper_Docs
{
public interface IWhatever
{
bool doSomething();
}
class Program : IWhatever
{
static void Main(string[] args)
{
var pro = new Program();
pro.doSomething();
}
public bool doSomething()
{
return true;
}
}
}
Example 2: c# interfaces
public class Car : IEquatable<Car>
{
public string Make {get; set;}
public string Model { get; set; }
public string Year { get; set; }
public bool Equals(Car car)
{
return (this.Make, this.Model, this.Year) ==
(car.Make, car.Model, car.Year);
}
}