构建可反转排序的泛型字典类(5)--实现IEnumerable接口2010-11-265. 实现IEnumerable<KeyValuePair<TKey, TValue>>接口我们先来看看ReversibleSortedList类的定义:
public class ReversibleSortedList<TKey, TValue> :
IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>,
IEnumerable<KeyValuePair<TKey, TValue>>, IDictionary, ICollection, IEnumerable
它一共实现了6个接口。但从本质上来说,实现IDictionary<TKey, TValue>接口和IDictionary接口就等同于实现了以上6个接口。因为 IDictionary<TKey, TValue>继承自 ICollection<KeyValuePair<TKey, TValue>>和 IEnumerable<KeyValuePair<TKey, TValue>>接口,而IDictionary 接口继承自ICollection和IEnumerable接口。下面我们来看一下这些接口的关系 图: