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

What is tryparse c#?

0 Answers  


If you want to write your own dot net language, what steps you will u take care?

0 Answers  


How to Show Message box in Metro Style App?

0 Answers   PUCIT,


What is raise event and what is its use?

1 Answers   Wipro,


What?s a delegate?

8 Answers   CTS, Visual Soft,


What is a function c#?

0 Answers  


How to create multi-dimensional array?

0 Answers   C DAC, CDAC,


What is an int c#?

0 Answers  


What is type safe code?

0 Answers  


what is the difference between c-sharp and vb.net?What kind of security or advances we find in both languages?

3 Answers   DataPoint,


How do you define a predicate?

0 Answers  


Explain how to parse a datetime string?

0 Answers  


Categories