Last post Oct 08, 2017 01:18 PM by avis123
Oct 07, 2017 09:33 PM|avis123|LINK
I have written code to generate random number using a loop and writing the output in a list box. However I am also trying to figure out as to how to write the output in a file instead of a list box. I cannot seem to figure this out. I have not done much
of file handling before,
I would appreciate any help or links to article that would help me handle this. Thanks in advance.
private void generateNumbers_Click(object sender, EventArgs e)
//Declare a variable to hold the number of random numbers to be generated.
//Assign the text value to the above variable that user writes in the control numberOfRandomNumberTextBox
num_of_random_numbers = int.Parse(numberOfRandomNumberTextBox.Text);
//Create a random object
Random rand = new Random
//Use a loop to generate the random numbers.
//We also display those number in the list box randomNumberListBox
for (int count = 1; count <= num_of_random_numbers; count++)
//Declare a variable to hold the random number
//Get the random number and assign it to the variable number
number = rand.Next(100) + 1 ;
//Add the generated random number to the list box
Oct 08, 2017 01:18 PM|avis123|LINK
Never mind. I figured it how. Thanks