A class is said to implement an interface. Each class that implements an interface usually must fully define each of the interface members. At least, in C#, interface implementation works on the principle: all or nothing. You cannot choose what to implement and what not to implement. While class can inherit only one class, it can implement any number of interfaces. Interfaces can be used for inheritance, similar to the use of base classes. Another possibility, perhaps even more significant, is to use multiple interfaces to implement the "supports functionality" relationship (i.e., new functionality is added to an existing class).
In C#, there are standard interfaces, such as IСomparable and IСomparer - used for comparing objects. To use the Array.Sort() method to sort an array of user-defined objects, the user-defined class must implement the IСomparable interface (generic or not). This interface contains a prototype for a single method - CompareTo(object obj), which is used to perform object comparison. This method returns an integer value (-1, 0, 1).
To compare objects by two different attributes, you can use, in addition to the IСomparable interface, the IComparer interface, which contains a prototype for the Compare(object x, object y) method.
Here are some interesting PDF books about Interfaces in OOP:
C# OOP Step by Step: A Practical Guide with Examples
2025 by William E. Clark

Download PDF
Object-Oriented Programming with Python: Best Practices and Patterns
2024 by Robert Johnson

Download PDF
Java OOP Simplified: A Practical Guide with Examples
2025 by William E. Clark

Download PDF
See also: Top 10 eBook Organizers
How to download PDF:
1. Install Gooreader
2. Enter Book ID to the search box and press Enter
3. Click "Download Book" icon and select PDF*
* - note that for yellow books only preview pages are downloaded


