I am new to C#, I have a code that calls the same function 3 times that returns a random sting. For some reason my code is returning the same string all the time. Please help.
public static String randomString()
{
String chars = "QWERTYUIOPASDFGHJKLZXCVBNM";
Random rand = new Random();
String finalstring = null;
for (int i = 0; i < 8; i++)
{
finalstring += chars[rand.Next(0, chars.Length - 1)];
}
return finalstring;
}
public void SecondTest()
{
Console.WriteLine(Class1.randomString());
Console.WriteLine(Class1.randomString());
Console.WriteLine(Class1.randomString());
}
Sample Output observing: AXCFSDRG AXCFSDRG AXCFSDRG