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 Interface Polymorphism?with E.g



What is Interface Polymorphism?with E.g..

Answer / sandeep negi

//Consider IShape interface like this

interface IShape
{string CalculateArea();}

class Circle : IShape
{
public string CalculateArea(){return "Circle area";}
}

class Rectangle : IShape
{
public string CalculateArea(){return "Rectangle
area";}
}


//implement function
private string ProcessArea(IShape shape)
{return shape.CalculateArea();}

//call this function from main or from button click event
like this

private void button1_Click(object sender, EventArgs e)
{
Rectangle r = new Rectangle();
Circle c = new Circle();
MessageBox.Show(ProcessArea(r));
MessageBox.Show(ProcessArea(c));
}

Is This Answer Correct ?    3 Yes 2 No

Post New Answer

More C Sharp Interview Questions

If c# destructors are so different to c++ destructors, why did ms use the same syntax?

0 Answers  


What are native functions?

0 Answers  


What is gac? How to put assembly in gac?

0 Answers  


What are the access-specifiers available in c#?

26 Answers   Syntel,


Can a method return multiple values in c#?

0 Answers  


How can we sort an array in c#?

0 Answers  


What is generic collection in c#?

0 Answers  


Which string method is used for concatenation of two strings in c#?

0 Answers  


What’s a strong name?

0 Answers  


Explain About disco and uddi

0 Answers   Digital GlobalSoft,


What is a hashset c#?

0 Answers  


What is xaml in c#?

0 Answers  


Categories