Perform IEnumerable method
.net, c#, lambda, linq
Solution
How about
range.Where(i => i <= UserInput).Max();
and
range.Where(i => i >= UserInput).Min();
Or Alternatively
range.Max(i => i <= UserInput);
range.Min(i => i >= UserInput);
Problem
Simplying the problem statement to List of int, lets say I have this ``` List<int> range = new List<int>(10) { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 }; ``` User inputs 24, I would need a Early feed value as 20 and late feed value as 30 User inputs 99, I would need a Early feed value as 90 and late feed value as 100 User inputs 20, I would need a Early feed value as 20 and late feed value as 20 Is there a Lamba Expression or linq statement to get this sort of result. My real input is not List of int, I have just simlified it, more keen on the lamba or linq expression to get the result