今天在实现一个小功能 “插入更新 ListBox 中的 Item ”时,发现 ListBox.Items
的类型 ListBox.ObjectCollection
实现了 IList
, ICollection
, IEnumerable
三个接口,整体的方法已经非常接近一个数组,但是方便程度跟数据确实差距较大,Linq 也完全不能使用,故封装一个扩展方法实现直接获取 ListBox.Items
中所储存的数据的集合。
1 | using System; |
今天在实现一个小功能 “插入更新 ListBox 中的 Item ”时,发现 ListBox.Items
的类型 ListBox.ObjectCollection
实现了 IList
, ICollection
, IEnumerable
三个接口,整体的方法已经非常接近一个数组,但是方便程度跟数据确实差距较大,Linq 也完全不能使用,故封装一个扩展方法实现直接获取 ListBox.Items
中所储存的数据的集合。
1 | using System; |
微信支付
支付宝