I'm writing small program of generating 30000 distinct alphanumeric codes and I want the program to print the count of already generated codes every time it is divisible by 1000. When I run it it does not print it like
1000
2000
3000
and so on. Instead it prints it like this
It does not happen when I step into and go step by step. The following is the code
static void Main(string[] args)
{
char[] charSequence = { '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y' };
Console.WriteLine(charSequence.Length);
HashSet<string> set = new HashSet<string>();
while (set.Count < 30000)
{
CodeGenerator cg = new CodeGenerator();
Random rnd = new Random();
string code = "";
for (int i = 0; i < 8; i++)
{
int charSequenceNumber = rnd.Next(charSequence.Length);
code += charSequence[charSequenceNumber];
}
set.Add(code);
if (set.Count % 1000 == 0)
{
Console.WriteLine(set.Count);
}
}
Console.WriteLine();
Console.ReadLine();
}
Am I doing something wrong?