An interface is look like classes but in interface have no implementation. It contains the declaration of events,methods, indexers and properties. Interfaces provide only declaration because they are inherited by classes and structs which must provide implementation for each interface member declared.
{
void ImplementationToMethod();
}
{
static void main()
{
ABC a1=new ABC();
a1.ImplementationToMethod();
}
public void ImplementationToMethod()
{
Console.WriteLine("ImplementationToMethod() called.");
}
}
Defining an Interface:-
interface IUInterface{
void ImplementationToMethod();
}
Using and Interface:-
Class Abc:IUInterface{
static void main()
{
ABC a1=new ABC();
a1.ImplementationToMethod();
}
public void ImplementationToMethod()
{
Console.WriteLine("ImplementationToMethod() called.");
}
}
No comments:
Post a Comment