I found some code that is suppose to work with LinQ and i modified it. It suppose to find the closest value in a list.
fibo = 1.23 and zlist has a bunch of numbers in it. I want to find the closest number to 1.23 in the zlist.
List<double> list = new List<double>() {zlist[z]};
double number = fibo;
double closest = list.Aggregate((x,w) => Math.Abs(x-number) < Math.Abs(w-number) ? x : w);
Print(closest);
Its not returning the closest number, it just returning the entire list. Does it have to do with LinQ?
Comment