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 use of properties window?
What do you mean by delegates and explain different types of delegates?
What is yield return in c#?
Describe two uses of the “using” statement during the operation of c#?
What is a base class in C#?
0 Answers TryTechnicals Pvt Ltd,
What is Partial class? What purpose we use it?
What's the implicit name of the parameter that gets passed into the set method/property of a class?
What is an indexer in c#?
What is difference between list and dictionary in c#?
Why is c# a good programming language?
What are c# i/o classes?
What?s the role of the DataReader class in ADO.NET connections?