In one of my interviews I face this problem as why you use your interface as below mention
Interface
Interface Irepo{
void add(int a, int b);
}
Repo.cs
Public Class Repo:Irepo{
public void add(int a, int b){
}
HomeContrller
Public Clas HomeController:ApiController{
Private readonly Irepo _Iobjrepo;
public HomeController(){
_Iobjrepo =new Repo();
}
}
Please help me why to use Irepo in constructor of HomeController. What is its use?