C#, LINQ. How to find an element within group of elements

Posted by Bobb on Stack Overflow See other posts from Stack Overflow or by Bobb
Published on 2010-05-21T21:28:07Z Indexed on 2010/05/21 21:30 UTC
Read the original article Hit count: 189

Filed under:
|

Imagine you have int[] data = new int [] { 1, 2, 1, 1, 3, 2 }

I need sub-array with only those which conform to a condition data[i] > data[i-1] && data[i] > data[i + 1]... i.e. I need all items which stick over their immediate neighbours.

From example above I should get { 2, 3 }

Can it be done in LINQ?

Thanks

© Stack Overflow or respective owner

Related posts about c#

Related posts about LINQ