我想转换IEnumerable<Target>
:
public class Target
{
public Frame BaseFrame;
public Rect[] rects;
}
致IEnumerable<foo>
:
public class foo
{
public Frame BaseFrame;
public Rect rect;
}
e.g。将Rect[]
数组,IEnumerable<Target>
扩展为IEnumerable<foo>
,如何在此函数上编写LINQ?
示例:
目标序列:
t1(rects.Count==2), t2(rects.Count==3)
foo的序列(转换后):
f1, f2, f3, f4, f5
答案 0 :(得分:5)
var q = from t in targets
from r in t.Rects
select new foo
{
BaseFrame = t.BaseFrame,
Rect = r
};