I want to find the closest number in a list. i found that code and i want to adapt it to my problem.
List list = new List() {alist[a]}; double number = fibo;
double closest = list.Aggregate((x,w) => Math.Abs(x-number) < Math.Abs(w-number) ? x : w);
In my case the list already exist and its alist[a]. fibo is a value that can represent 1.2 for exemple and alist[a] include possible numbers close to fibo value. id like to change that into an if statement or a for.
ty
Aucun commentaire:
Enregistrer un commentaire