开发者

Behavior of ObservableCollection(IEnumerable) constructor

开发者 https://www.devze.com 2022-12-17 02:14 出处:网络
According to MSDN there is an overload for the ObservableCollection constructor to which you can pass an IEnumerable. According to the very short MSDN page th开发者_如何学Cis will make a \"Copy\" of t

According to MSDN there is an overload for the ObservableCollection constructor to which you can pass an IEnumerable. According to the very short MSDN page th开发者_如何学Cis will make a "Copy" of the Ienumerable.

How do I determine how this will behave? Will the "Copy" be totally independent of the original or will changes made to the Ienumerable (Such as by a linq query) be reflected automatically in the ObservableCollection?

MSDN Page


This constructor walks through the items in the IEnumerable and adds each one to the ObservableCollection. Once this is finished the new ObservableCollection has nothing more to do with the IEnumerable (except that if you are dealing with a collection of reference types then the ObservableCollection will hold references to the same objects that were supplied by the IEnumerable).

0

精彩评论

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

关注公众号