Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void generateButton_Click(object sender, EventArgs e)
- {
- // Create an array to hold the numbers.
- const int SIZE = 5;
- int[] lotteryNumbers = new int[SIZE];
- // Create a Random object.
- Random rand = new Random();
- // Fill the array with random numbers, in the range // of 0 through 99.
- for (int index = 0; index < lotteryNumbers.Length; index++)
- {
- lotteryNumbers[index] = rand.Next(100);
- }
- // Display the array elements in the Label controls.
- firstLabel.Text = lotteryNumbers[0].ToString();
- secondLabel.Text = lotteryNumbers[1].ToString();
- thirdLabel.Text = lotteryNumbers[2].ToString();
- fourthLabel.Text = lotteryNumbers[3].ToString();
- fifthLabel.Text = lotteryNumbers[4].ToString();
- }
- private void exitButton_Click(object sender, EventArgs e)
- {
- // Close the form.
- this.Close();
- }
- declare resultVariable
- loop all numbers in lotteryNumbers
- add current number in lotteryNumbers to resultVariable
Add Comment
Please, Sign In to add comment