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

Why is it a bad idea to throw your own exceptions?

4 Answers  


what is reference parameter? what is out parameters? what is difference these two?

9 Answers   Bally Technologies, SPIC, Wipro,


Are structs value types or reference types?

0 Answers  


What are predicates in c#?

0 Answers  


Is c# still popular?

0 Answers  


Explain the OOPS concept in C#?

0 Answers   HCL,


Which type of variables are under the control of garbage collector?

4 Answers   Kanbay,


What are virtual destructors?

0 Answers   InfoAxon Technologies,


What debugging tools come with the .NET ssSDK?

0 Answers   Siebel,


Can a class inherit structure.

4 Answers   IBM, Synechron,


What is extended class in c#?

0 Answers  


Explain the different ways a method can be overloaded?

0 Answers  


Categories