Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,959 questions

51,901 answers

573 users

How to generate random double number in a range with C#

1 Answer

0 votes
using System;

public class Program
{
    public static double GetRandomDoubleNumber(double minimum, double maximum) { 
        Random random = new Random();
        
        return random.NextDouble() * (maximum - minimum) + minimum;
    }
    public static void Main() {
        for (int i = 0; i < 10; i++) {
            Console.WriteLine(GetRandomDoubleNumber(3.14, 8.91));
        }
    }
}
 
 
 
 
 
/*
run:
 
7.71211766828881
8.63509345064177
3.5845902550335
7.3651441648673
6.93486355700291
3.79821178533054
6.15149303793045
8.84103314612575
5.73810841647354
7.24172805962699
 
*/

 



answered Aug 14, 2023 by avibootz

Related questions

1 answer 130 views
1 answer 105 views
4 answers 411 views
2 answers 160 views
1 answer 112 views
1 answer 206 views
...