I want to generate random (double) numbers between two limits, let say: lim1 and lim2.
But, I want this numbers to be generated in order. E.g.: between 1 and 6 : 1.53412 1.654564 2.213123 5.13522 . Thanks!
I want to generate random (double) numbers between two limits, let say: lim1 and lim2.
But, I want this numbers to be generated in order. E.g.: between 1 and 6 : 1.53412 1.654564 2.213123 5.13522 . Thanks!
 
    
     
    
    public static double[] GenerateRandomOrderedNumbers(double lowerBoundInclusive, double upperBoundExclusive, int count, Random random = null)
{
    random = random ?? new Random();
    return Enumerable.Range(0, count)
        .Select(i => random.NextDouble() * (upperBoundExclusive - lowerBoundInclusive) + lowerBoundInclusive)
        .OrderBy(d => d)
        .ToArray();
}
Not perfect, but I hope this puts you in the right direction.
 
    
    Generate the random numbers and put them on a list:
var numbers = new List<int>();
Random random = new Random();
Add your numbers:
var number = random.Next(min, max); 
numbers.Add(number);
Then sort the list:
var orderList = from n
  in numbers
  orderby n
  select n;
 
    
    What about using this to generate a set of random numbers:
lim1 + random.Next(lim2 - lim1)
and then simply sorting them?
 
    
    