Possible Duplicate:
Why would I want to use Interfaces? Why I need Interface?
I want to know where and when to use it?
For example,
interface IDemo
{
// Function prototype
public void Show();
}
// First class using the interface
class MyClass1 : IDemo
{
public void show()
{
// Function body comes here
Response.Write("I'm in MyClass");
}
}
// Second class using the interface
class MyClass2 : IDemo
{
public void show()
{
// Function body comes here
Response.Write("I'm in MyClass2");
Response.Write("So, what?");
}
These two classes has the same function name with different body. This can be even achieved without Interface. Then why we need an Interface where and when to use it?