Create textfile populated with random numbers. Number of random numbers to be generated received from inputbox
//write to textfile
StreamWriter outputFile;
try
{
outputFile = File.CreateText("randomNumbers.txt"); //open
//declare and assign variables
int randomNumbersInput = int.Parse(txtNum.Text);
for(int k = 0; k< randomNumbersInput; k++)
{
int randNumber;
Random rand = new Random();
randNumber = rand.Next(100 + 1);
outputFile.WriteLine(randNumber);//process
}
outputFile.Close(); //close file
MessageBox.Show("File saved successfully");
Aucun commentaire:
Enregistrer un commentaire