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 |
Is datetime value type c#?
Does c# support const methods, properties, or events?
hi all.... i need code snippets for store and retrive tiff fromat images in sqlserver....... kindy provide it.......
How do you create dlls in .NET
Are arrays immutable c#?
What's the difference between System.String and System..StringBuilder in C#?
can we declare a variable by name "this" in a class? Please explain?
Is int reference type c#?
What is exe in c#?
What is the use of table aliases?
How is method overriding different from overloading?
What are circular references?