Click here to Skip to main content
15,886,074 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
At first between xmin, xmax a random number x . And then between xmin, x is a random number to find another with C #


What I have tried:

Part of the training instructor for the semester
[EDIT - OP code from a comment]
C#
Random r = new Random();
 for (int i = 0; i < int.Parse(popsizetxt.Text); i++)
 {
 x = r.Next(Int32.Parse(xmin.Text), Int32.Parse(xmax.Text)) + r.NextDouble();

 x = r.Next(Int32.Parse(xmin.Text), Int32.Parse(xmax.Text)) + r.Next();
Posted
Updated 5-Apr-16 10:40am
v2
Comments
CHill60 5-Apr-16 15:46pm    
The "What I have tried:" section is for you to post the code you are struggling with. We won't do your homework for you
paris jiji 5-Apr-16 15:52pm    
I'm working on a thesis project was an error when trying to run the program I wrote that the value xmin xmax must be greater

a part of program


Random r = new Random();
for (int i = 0; i < int.Parse(popsizetxt.Text); i++)
{
x = r.Next(Int32.Parse(xmin.Text), Int32.Parse(xmax.Text)) + r.Next();

x = r.Next(Int32.Parse(xmin.Text), Int32.Parse(xmax.Text)) + r.Next();
CHill60 5-Apr-16 15:54pm    
What was the error?
paris jiji 5-Apr-16 15:58pm    
' MinValue ' can not be larger than MaxValue value .
CHill60 5-Apr-16 16:33pm    
Nothing in the code you have shared produces that error.
We can't help you if we can't see the code!

1 solution

Random.Next() and Random.NextDouble() are not the only Random members.
There is also Random.Next(int, int):
Random.Next Method (Int32, Int32) (System)[^].

Is it so hard to look at the class definition?

—SA
 
Share this answer
 
v2
Comments
paris jiji 5-Apr-16 17:05pm    
Based on this , but I saw it I was wrong !!!!
Sergey Alexandrovich Kryukov 5-Apr-16 22:35pm    
I hope you're done by now.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900