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
Jonathan Crispe
NA
46
48.4k
Array random numbers for doubles
Oct 25 2011 7:46 PM
so far i have this: i couldn't figure out how to make an array.
Generate button, i called it BTN_generate
public partial class Form1 : Form
{
Random random = new Random();
double dtotal = 0;
public Form1()
{
InitializeComponent();
}
private void BTN_generate_Click(object sender, EventArgs e)
{
int irandom = random.Next(0, 100);
double drandom = random.NextDouble();
dtotal = irandom + drandom;
textBox1.Text = dtotal.ToString("0.00");
}
}
and i tried without double drandom = random.NextDouble();
public partial class Form1 : Form
{
int[] iArray = new int[20];
Random rNumber = new Random(101);but my code didn't work
private void BTN_generate_Click(object sender, EventArgs e)
{
for (int i = 0; i < iArray.Length; i++)
{
iArray[i] = rNumber.Next(101);
}
Console.WriteLine();
foreach (int iValue in iArray)
{
textbox1.Text = iValue.ToString();
}
}
}
this one is just giving me one number.
Reply
Answers (
3
)
C# 2010 linq problem
Why does Project gets automatically saved?