Wednesday 1 February 2012

Implementation of Interface in C#

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.

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