How to find multiple numbers in a list and test the number again?

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

Frankdot

Guest
Hello,

double find = 0;

var listQ = new List<double>() {1,3,3.2,4,4.1,5};

double i = 3.5;

find = listQ.Aggregate((x, y) => Math.Abs(x - i) < Math.Abs(y - i) ? x : y);



Print("item"+find);

// find will return 3.2
//now i want to find the closest number from 3.2
// that would be 3 ...

Is there a method allowing me to do that? So that the variable i always = find? The result from find must take the place of i.


Thank you

Continue reading...
 
Back
Top