checking elements in a List

  • Thread starter Thread starter Frankdot
  • Start date Start date
F

Frankdot

Guest
Hello,

I am trying to find the closest number in a list. But the lambda always return the last element of the list and not the number of my variable fibo2.


double newvol = sumvolms / sumvols;


List<double> zlist = new List<double>() {newvol};

double minDistance = list.Min(no => Math.Abs(fibo2- no));

double closest = list.First(no => Math.Abs(fibo2- no) == minDistance);




//if list return 1, 2, 3 and fibo2 = 1, the lambda return 3. It should return 1.



Any idea why it does that?

Thank you

Continue reading...
 
Back
Top