Interface are a type similar to class, where it cannot have the Method Content, rather it has the definition of Method. It will not have properties and members variables. The class which inherits the interface should implement all the methods of the interface. The interface forces the derived class to implement; otherwise it will not get compiled.

The below lists some of common interfaces of .Net
1. IComparable - Implemented by types whose value can be ordered, it is used for sorting.
2. Idisposable - Defines this method to dispose of an object manually, this is important most commonly used Interface when dealing with more big objects, and also to release the object which holds the resource like database.
3. IConvertible - Enables the class to base type such as string, int or bool.
4. IClonable - Supports object copying
5. IEquatable - Allows comparing to object instances.
6. IFormatable - Provides way to convert the value of object into a formatted string. This is similar to ToString() method, but provides greater flexibility than it.

No comments:

Post a Comment