我有:
IEnumerable<ObservableCollection<PointCollection>> rings =
from graphic
in e.FeatureSet
select ((Polygon)e.FeatureSet.Features).Rings;
我想从每个图形中提取所有 PointCollection,并将它们合并到一个 ObservableCollection 中。像这样:
ObservableCollection<PointCollection> allRings = ?;
有没有更好的方法可以在不执行一堆嵌套的 ForEach 语句的情况下进行迭代?
最佳答案
你可以使用 SelectMany
:
var allRings = new ObservableCollection<PointCollection>(
rings.SelectMany(rings => rings)
);
关于c# - 从 IEnumerable<ObservableCollection<T>> C# 中提取项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13575518/