Implementing Interfaces: Comparing Objects When Sorting

Learn how interfaces in C# enable types to implement standard functionality, such as IComparable for sorting, enhancing code flexibility and reusability.

Interfaces are a way to implement standard functionality and connect different types to make new things. Think of them like the studs on top of LEGO bricks, which allow them to “stick” together, or electrical standards for plugs and sockets. If a type implements an interface, it promises to the rest of .NET that it supports specific functionality. Therefore, they are sometimes described as contracts.

Get hands-on with 1400+ tech skills courses.