Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


What is the Use Of Interfaces?
For example I have a interface as shown below?

Interface IMyInterface
{
public void MyMethod();
}

class MyClass : IMyInterface
{
public void Mymethod()
{
Some Code
}
}

class Program
{
static void Main(string[] args)
{
MyClass obj = new MyClass();
obj.MyMethod();
}
}

Here What is My Question is?

If i remove Interface and run this code, it will executed then what is the Use
of the interface? Can any one give me the solution for this Problem?

Thanks in Advance!



What is the Use Of Interfaces? For example I have a interface as shown below? Interface IMyInter..

Answer / sheetal

Offcourse it works if you remove the interface. What is the
purpose of interface is : if you implementing any interface
you need to define all the methods declare in interface in
your class. In this code snippet implement the interface
and do define method in class and compile the program. It
will give you compile time error.

Interface IMyInterface
{
public void MyMethod();
}

class MyClass : IMyInterface
{
//DO NOT DEFINE MyMethod()
}

Is This Answer Correct ?    6 Yes 3 No

Post New Answer

More C Sharp Interview Questions

In a site to turn off cookies for one page which method is followed?

0 Answers   Siebel,


What is Implementation inheritance

0 Answers  


How do you access a constant field declared in a class?

0 Answers  


What is the namespcae generally given to the webpage of the .NET Framework ?

0 Answers   Siebel,


What is difference between first and firstordefault?

0 Answers  


You have got 1 million parking slots. At a time a parking slot can be free or not. To get next slot easily which data structure to implement?

0 Answers  


Explain publishers and subscribers in events.

0 Answers  


What is out in c#?

0 Answers  


What is data binding c#?

0 Answers  


If a.equals(b) is true then a.gethashcode & b.gethashcode must always return same hash code.

0 Answers  


What is the difference between a field and a property in c#?

0 Answers  


What is delegates and events?

0 Answers  


Categories