How to use LINQ for this query?

I want to convert IEnumerable<Target>from:

public class Target
{
        public Frame BaseFrame;

        public Rect[] rects;
}

To IEnumerable<foo>of:

public class foo
{
      public Frame BaseFrame;
      public Rect rect;
}

eg. expand the array Rect[], IEnumerable<Target>before IEnumerable<foo>, how to write LINQ for this function?

Example:

target sequence:

t1(rects.Count==2), t2(rects.Count==3)

sequece foo (after conversion):

f1, f2, f3, f4, f5
+3
source share
1 answer
var q = from t in targets
        from r in t.Rects
        select new foo
        {
          BaseFrame = t.BaseFrame,
          Rect = r
        };
+5
source

Source: https://habr.com/ru/post/1735702/


All Articles