简体   繁体   中英

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. Something like this:

ObservableCollection<PointCollection> allRings = ?;

Is there a better way to iterate this without doing a bunch of nested ForEach statements?

You could use SelectMany :

var allRings = new ObservableCollection<PointCollection>(
    rings.SelectMany(rings => rings)
);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM