IEnumerable,ICollection,IList接口问题
最近有一个疑问:IList已经继承了ICollection<T>,而ICollection<T>继承了IEnumerable<T>, IEnumerable,那为什么IList还要继承IEnumerable<T>, IEnumerable?


于是我自己写了接口测试:用dnSpy反编译看到,Test3接口继承了Test1,Test2。这就说明接口其实不支持跟类一样的继承的,但是我们实际用的时候却跟类用法一样,好像支持继承,这其实是编译器帮我们补齐了接口的定义,添加上了Test1。


相关推荐
Crazyshark 2019-07-17