问题
...or can I use ICollection with no problem?
I mean, I don't think ICollection was designed for Sorted collections because that could break an application designed for sorted or unserted ICollection objects, but I don't know.
回答1:
I'd say the ICollection<T> Interface is suitable for implementation by sorted collection types, because a sorted collection can be enumerated, added to, removed from, cleared and checked for its contents.
As a counter-example, the IList<T> Interface is probably not suitable, because unlike ICollection<T> it assumes that the collection is a list where the elements can be added at specific positions, which doesn't make sense if the collection itself determines the position of each element.
The sorted collection types in the .NET Framework (the SortedList<TKey, TValue> Class, SortedDictionary<TKey, TValue> Class, and SortedSet<T> Class) all implement ICollection<T> but not IList<T>.
来源:https://stackoverflow.com/questions/13131167/is-there-an-interface-like-icollectiont-but-designed-for-sorted-collections