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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

Can abstract class have constructor c#?

813


Can abstract class be sealed?

833


Why do you call it a process? What’s different between process and application in .net, not common computer usage, terminology?

950


What is difference between struct and class in c#?

866


Can a class or a struct have multiple constructors?

898


Which is faster dictionary or list?

867


What is a interface in c#?

920


How objects are stored in memory?

929


What is 8 bit signed integer?

866


What is difference between il and dll ?

932


What is the data type for bit in c#?

887


What are the Types of values mode can hold session state in web.config

944


How do you prevent a method from being overridden in c#?

809


What are modifiers in c#?

822


What is the difference between a variable and a literal?

990