dimanche 26 juillet 2015

How to generate a true (synchronized) random set of strings in a variable? [duplicate]

This question already has an answer here:

I thought i can generate some random strings but i kept getting the same answer :/, there is a lot complexity with random generation and is the reason why my code sucks, here is what i thought would work:

class Program
{
    static void Main(string[] args)
    { 
            for (int i = 0; i < 10; i++)
            {
                string[] mystrings = "vice|virtue|samuel|fruits".Split('|');
                int choice = new Random().Next(mystrings.Length);                
                Console.WriteLine(mystrings[choice]);                   
            }                
        }
    }

i get the same answer :/, i have researched here for a solution but it's for integers like 0-1000 random number generation, mine is for strings which i could not find in the forums and some keywords i saw were 'synchronized'




Aucun commentaire:

Enregistrer un commentaire