I am trying to make a key generator that generates upper case, lower case and numeric keys.
My current code below generates duplicates keys, using random numbers.
How could I update it to generate unique keys?
public static void printLowerCaseKeys()
{
string array = "";
int k = 0;
if (sDelimeterOption == "yes")
{
while (k < sKeyLength)
{
for (int i = 0; i < sDelimeterCharPosition; i++)
{
if (k >= sKeyLength)
break;
array = array + (char)r.Next(97, 123);
k++;
}
if (k < sKeyLength)
{
array = array + sDelimeterChar;
k++;
}
}
}
else
{
while (k < sKeyLength)
{
array = array + (char)r.Next(97, 123);
k++;
}
}
Console.WriteLine(array);
}
You could use the GUID class!
Every GUID is unique, even among other systems.
System.GUID.NewGuid().ToString()