Collection类中的接口实现 [英] Interface implementation in Collection Class

查看:118
本文介绍了Collection类中的接口实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个与Collection< t>相关的问题。课程。



收集课程是:



I have a question related to the Collection<t> class.

The collection class is:

class Collection<T> : IList<T>, ICollection<T>, IEnumerable<T>, IList, ICollection, IEnumerable





为什么Collection类实现ICollection和IEnumerable,它已经存在于IList中。收集< t> class正在实现IList,因此它将隐式具有ICollection和IEnumerable。





Why does the Collection class implements ICollection and IEnumerable when it is already present in the IList. The Collection<t> class is implementing IList so it will implicitly have ICollection and IEnumerable.

public interface IList : ICollection, IEnumerable

推荐答案

可能只是为了当你看到IList确实包含ICollection和IEnumerable的文档时提醒你!



如果使用VS快捷方式实现界面,你将获得相同的函数原型,所以它可能只是一个文档的东西 - 你的班级没有必要这样做,除非你想要文档的完整性。如果您需要,VS Explicit实现包括适当的类前缀。
Probably, just to remind you when you look at the documentation that IList does include ICollection and IEnumerable!

If you use the VS shortcut to implement the interface you will get the same function prototypes regardless, so it is likely just a documentation thing - there is no need in your class to do the same, unless you want the completeness in your documentation as well. A VS Explicit implementation includes the appropriate class prefix if you need it anyway.


这篇关于Collection类中的接口实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆