I have a IEnumerable<Object> a with 6 items in chronological order in it.
I want to test if list IEnumerable<Object> b with 3 items in chronological order.
IEnumerable<Object> a item values: a,b,c,d,f,g
IEnumerable<Object> b item values: b,d,f
Is it possible to be done with LINQ ?
You can use the following:
bool AContainsEverythingInBInTheSameOrder =
    a.Intersect(b).SequenceEquals(b);
a.Intersect(b) returns everything that is in both a and b, in the same order in which it appears in a.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With