开发者

difference between IList and IBindingList [duplicate]

开发者 https://www.devze.com 2023-03-27 20:18 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: List<T> vs BindingList<T> Advantages/DisAdvantages
This question already has answers here: Closed 11 years ago.

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


They are designed for different scenarios

  • IList is designed to be a very efficient container of objects. It's minimalistic
  • IBindingList 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 than IList (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.


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 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

0

精彩评论

暂无评论...
验证码 换一张
取 消