TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
njsbenson
NA
1
0
Random numbers and loops
Jan 8 2005 6:35 AM
I have a method which generates random numbers to produce other object with those variables inside a for loop. However each cycle through the loop generates the same random numbers. Could anybody tell how to generate new random numbers for each cycle. public Genome(int l) { length = l; g = new Gene[length]; Random r = new Random(); for(int i = 0; i < length; i ++) { int x = r.Next(100); int z = r.Next(100); int a = r.Next(5); int b = r.Next(10); int c = r.Next(-3,3); g[i] = new Gene(x,z,a,b,c); g[i].CalcOutput(); } }
Reply
Answers (
1
)
validation of C#
Stop program execution for a specified time