I have an IEnumerable<float>
containing distinct values found in a three dimensional array.
Given a test value, I want to take two elements from my distinct IEnumerable
, the closest value which is greater than or equal to the test value, and the closest value which is less than the test.
In other words, if my test value is 80.5, and my list contains:
- 1.0
- 1.65
- 2.345
- 99.439
Then I want an IEnumerable<float>
or a Tuple<float,float>
back which contains 2.345 and 99.439.
Is there a LINQ statement or combination of such which will do that? An approach without LINQ?