I am trying to write a program which picks the closest number possible out of a dictionary.
The dictionary contains 50 doubles values, and I use a random double to pick the number i want to get the closest to if that makes sense.
Currently I am using linq to pick the first one which is less or equal to the random number. The problem I have found with this is that it is not reaching numbers which are closer and its most certainly picks the same key all the time. I have also tried the SkipWhile method but I have not seen much of a difference. Also tried to 'shuffle' the dictionary before finding the closest, which as help as now im not getting the same value.
Just curious, is there is a method I'm not trying which is better than what I am currently doing.