C# using Generics both in the Interface and its implementor class
问题 I want to create an interface that works for all the IComparable types. For example public interface SortAlgorithm<T> where T : System.IComparable<T> { List<T> Sort(List<T> input); } And I want its implementors to be generic as well with the same specification I provide in the interface. Like the example below public class InsertionSort<T> : SortAlgorithm<T> Here is my purpose for doing this. I want all my sorting algorithms to work with all types that implements the IComparable interface.