everestsh
everestsh
CC#
Created by everestsh on 1/17/2023 in #help
❔ Random Letter
using System;
using System.IO;

class GFG{

public static void Main(string[] args)
{
Random res = new Random();

String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

String randomstring = "";
for (int i = 0; i < 1000; i++){
for (int a = 0; a < 7; a++)
{

int x = res.Next(str.Length);
randomstring = randomstring + str[x];
}
string file = @"codes.txt";
File.WriteAllText(file, $"{randomstring}\n");
Console.WriteLine("Random alphanumeric String:" + randomstring);
}

}
}
using System;
using System.IO;

class GFG{

public static void Main(string[] args)
{
Random res = new Random();

String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

String randomstring = "";
for (int i = 0; i < 1000; i++){
for (int a = 0; a < 7; a++)
{

int x = res.Next(str.Length);
randomstring = randomstring + str[x];
}
string file = @"codes.txt";
File.WriteAllText(file, $"{randomstring}\n");
Console.WriteLine("Random alphanumeric String:" + randomstring);
}

}
}
I want it to make a bunch of random codes that is 7 characters long and w+ to a file and than after 1000 of these itll delete all the codes and start over again but why wont this work?
12 replies