How to get the closest number from a List<int>
with LINQ?
For example:
List<int> numbers = new List<int>();
numbers.Add(2);
numbers.Add(5);
numbers.Add(7);
numbers.Add(10)
I need to find the closest value in the list to number 9. In this case 10.
How can I do this with LINQ?