Interface class c#

Interface class is an entity only not a class. Interface classes cannot be implemented. Interface class can be used in sub classes. Interface class cannot be instantiated. Interfaces class is used in (C#) because ASP.Net has not ability of multiple inheritances so interface classes are introduced with great deal. With interface classes application become very robust & very flexibility in the application. Interfaces class is very beneficial when we are using small units of functions, in other way abstraction can be used when large units of functions are used.  A keyword “Interface” is used to define the class. Interface class is used in sub classes. Interface class has the ability to signature implementation.  An interface class has not access modifiers, everything is assumed public.

Interface Class In C#

An interface class can be member of namespace or class can. Interface class can contain signatures for the following members.
i)    Members
ii)    Indexers
iii)    Properties
iv)    Events

A class should implement interface members are specified in interface class. An example is given below to clear more view about interface class.
Interface AbcInterface
          Void TestMethod();
Class Test: AbcInterface
      Void samplemethod()
          //method implementation
     Static Void Main()
       //Declaring the interface instance
       AbcInterface obj = new Test ();
       //Calling the member
       Obj. TestMethod();

In short interface class provides great flexibility to design application & reduces the complexity of the application. It is highly recommended to use object oriented mythologies (OOPS) to make application more robust with neat & clean code.
Here is explained deeply Abstraction class and explained completely step by step difference between Interface and Abstraction Class

No comments:

Post a Comment