What are Interfaces ?
An interface is like an abstract base class. Any class or struct that implements the interface must implement all its members. An interface can't be instantiated directly. Its members are implemented by any class or struct that implements the interface. Interfaces can contain events, indexers, methods, and properties.
Basically Interfaces are only used to define method names and there is no implementation of method in Interfaces.
In Interface there is no access modifiers for methods.
Definition of methods or functions are done in classes calling them.
What are Abstract Classes in Dotnet ?
These classes are very similar to Interfaces where we only define the name of methods and no definition only the class using the method will have definition of methods.
Implementation of Abstract class is also very similar Lets see in Example.
Note :
1. Abstract Keyword is used to create Abstract Class in Dotnet.
2.Abstract Class can only be used as base class and no inheritance is provided with it.
3. Abstract Class cannot be instantiated as its incomplete.
4.Abstract Class cannot be sealed.
5
No comments:
Post a Comment