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 |
What is difference between throw and throws in c#?
What is default value of bool in c#?
What does it meant to say “the canonical” form of XML ?
What is difference between array and list in c#?
Major difference between Basic httpbinding and WShttpbinding?
I have to create a windows application using C# .net to Modifiy the XML file. The application have to show the node and node value. plz help me.
When do you generally use a class over a struct?
What is the real use of interface in c#?
What is constructor overloading in c#?
What is wpf c#?
Describe two uses of the “using” statement during the operation of c#?
Is c# a keyword?