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
Lior
NA
24
0
A very simple random problem-please help
Mar 16 2006 10:55 AM
Hi all
I wrote a simple code that should generate two different random numbers.
I designed a window in which I placed two labels and one button.
On the button click event the lebels should show two different numbers between 3-19.
the problem is when I click the button the two labels always show the same number when I use the "F11" to see the step by step happening inside the code the resault come out OK. why isn't it goes that way when I run(F5) the program???
the code goes somthing like that:
private void button1_click(....)
{
dieRoller myRoll = new dieRoller();
label1.text = myRoll.Roller().ToString();
label2.text = myRoll.Roller().ToString();
}
Class dieRoller
{
public int Roller()
{
int randNum;
Random roll = new Random();
randNum = (int)(roll.NextDouble()*16)+3;
return randNum;
}
}
what is wrong here???
Reply
Answers (
1
)
Problems with Windows Service and Outlook
Comm Port in VB.NET