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 the difference between hashtable and dictionary in c#?
What is Garbage Collection in .Net?
How many bytes is a char c#?
Is is possible to force garbage collector to run?
Illustrate the process of code compilation in c#?
Is array ienumerable c#?
What is Implicit conversion in C#?
So what makes your code really object-oriented #?
What are the fundamental oop concepts?
How do I open the console?
what is the difference between the debug class and trace class?
What is difference between ienumerable and ienumerator in c#?