Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use LINQ on this query?

I want to convert the IEnumerable<Target> of :

public class Target
{
        public Frame BaseFrame;

        public Rect[] rects;
}

To IEnumerable<foo> of :

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

e.g. expand the Rect[] array, IEnumerable<Target> to IEnumerable<foo>, how to write LINQ on this function?

example:

sequence of Target:

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

sequece of foo (after conversion):

f1, f2, f3, f4, f5
like image 792
Benny Avatar asked Jan 30 '26 17:01

Benny


1 Answers

var q = from t in targets
        from r in t.Rects
        select new foo
        {
          BaseFrame = t.BaseFrame,
          Rect = r
        };
like image 187
leppie Avatar answered Feb 01 '26 05:02

leppie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!