IList 和 IBindingList 的区别
可能的重复:
列表;与 BindingList 比较优点/缺点
IList 和 IBindingList 有什么区别?在 C# 中什么时候使用what以及什么时候不使用what? 公共接口IBindingList:IList, ICollection、IEnumerable
Possible Duplicate:
List<T> vs BindingList<T> Advantages/DisAdvantages
what is the difference between IList and IBindingList ? When to use what and where not to use what in C# ?
public interface IBindingList : IList,
ICollection, IEnumerable
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它们是针对不同场景而设计的
IList
被设计为一个非常高效的对象容器。它的简约IBindingList
被设计为一个对象容器,它提供了更丰富的 API,支持更多场景,例如 UI 数据绑定。如果您深入研究 API,您会发现
IBindingList
比IList
(没有)拥有更丰富的事件集合。它以额外的开销为代价,提供了更丰富的API,适合更多的场景,例如UI数据绑定。They are designed for different scenarios
IList
is designed to be a very efficient container of objects. It's minimalisticIBindingList
is designed to be a container of objects which provides a richer API that enables more scenarios such as UI data binding.If you dig into the APIs you'll find that
IBindingList
has a much richer event collection thanIList
(which has none). It takes the trade off of extra overhead to provide a richer API that fits more scenarios such as UI data binding.最好使用仅提供您需要的功能的界面,仅此而已。例如,如果您只需要顺序访问集合,IEnuerable 就足够了。
恐怕我无法帮助您解决有关 IBindingList 和 IList 之间差异的主要问题。
It's good practise to use the interface which provides just the functionality you need and nothig more. For example, if you only need sequential access to the collection IEnuerable should suffice.
I'm afraid I can't help you with your main question about the difference between IBindingList and IList.
IList 是用于保存一些数据的简单数据结构,它可以动态增长,并且包含 List 的其余正常功能,
而 Binding 列表用于在某些控件和集合之间绑定数据,因为当有数据存在时它会通知控件和集合。一项有助于特殊基于 UI 的应用程序的更改
IList is simple data structure used for holding some data and it can grow dynamically and it includes rest of the normal features of List
Whereas the Binding list is used for binding data between some control and a collection because it notifies both control and collection when there is a change which helps in specially UI based application