[英]Extract Items from IEnumerable<ObservableCollection<T>> C#
I have: 我有:
IEnumerable<ObservableCollection<PointCollection>> rings =
from graphic
in e.FeatureSet
select ((Polygon)e.FeatureSet.Features).Rings;
I want to extract all the PointCollection's from each graphic and consolidate them into a single ObservableCollection. 我想从每个图形中提取所有PointCollection,并将它们合并到一个ObservableCollection中。 Something like this:
像这样的东西:
ObservableCollection<PointCollection> allRings = ?;
Is there a better way to iterate this without doing a bunch of nested ForEach statements? 有没有更好的方法来迭代这个而不做一堆嵌套的ForEach语句?
You could use SelectMany
: 你可以使用
SelectMany
:
var allRings = new ObservableCollection<PointCollection>(
rings.SelectMany(rings => rings)
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.