Generic Interfaces
Using generics you can define interfaces that
define methods with generic parameters. In the linked list sample,
you’ve already implemented the interface IEnumerable<T> , which defines a GetEnumerator() method to return IEnumerator<T>. For many nongeneric interfaces
of .NET 1.0, new generic versions have been defined since .NET 2.0,
for example IComparable<T>:
In Chapter 5, “Arrays,” the nongeneric
interface IComparable that requires an
object with the CompareTo() method is
implemented with the Person class to
sort persons by lastname:
When implementing the generic version, it is no
longer necessary to cast the object to a
Person: