why we need interface in c# code example
Example: creating interface in C#
using System;
namespace Grepper_Docs
{
public interface IWhatever
{
bool doSomething(); //Interface methods don't have bodies or modifiers
}
class Program : IWhatever
{
static void Main(string[] args)
{
var pro = new Program();
pro.doSomething();
}
public bool doSomething() //methods must be public
{
return true;
}
}
}