Welcome to Dream.In.Code
Become a C# Expert!

Join 150,386 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,101 people online right now. Registration is fast and FREE... Join Now!




Arrays - Adding a number randomly created in it.

 
Reply to this topicStart new topic

Arrays - Adding a number randomly created in it., Creating random number, saving as array, copying it into a listbox.

papuccino1
3 Mar, 2008 - 08:27 AM
Post #1

D.I.C Head
**

Joined: 2 Mar, 2008
Posts: 91


My Contributions
Hello, I think my question is fairly easy for you pro's to answer. Any help would be appreciated.

Here's my code so far:

CODE
namespace BingoMarzo
{    
    public partial class Form1 : Form
    {
        Random RandomClass = new Random();
        string[] numcartones = new string[15];
        
        public Form1()
        {
            InitializeComponent();
        }

        

        private void button1_Click(object sender, EventArgs e)
        {
            int RandomNumber = RandomClass.Next(1, 100);

            numcartones[1] = Convert.ToString(RandomNumber);
            
            this.listBox1.Items.Add(numcartones[1]);
            
                      
        }
    }
}


It generates a random number and adds it to the listbox. But I want it to the save the randomnumber in position 0 of the array, then create another random and save to position 1, etc. I hope I'm explaining myself well. Any help? smile.gif
User is offlineProfile CardPM
+Quote Post

zakary
RE: Arrays - Adding A Number Randomly Created In It.
3 Mar, 2008 - 10:23 AM
Post #2

D.I.C Regular
Group Icon

Joined: 15 Feb, 2005
Posts: 420



Thanked: 8 times
Dream Kudos: 175
My Contributions
so add a loop to your code
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 05:04PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month