jeudi 22 septembre 2016

select randomly from string array without repetitions

Good day I have some problem regarding selecting a random string from my string array I am currently developing a guessing word game. this is my string array:

 string[] movie = {"deadpool", "batmanvssuperman", "findingdory", "titanic", "suicidesquad", "lordoftherings", "harrypotter", "jurassicpark", "hungergames", "despicableme" };

while this is the process in selecting a random string to my array, what should i do next, because I want to select the string not repeated. e.g when the program starts it will select a string then when i select random string again i want to not select the previous word that i've already selected previously.

string word = movie[r.Next(0, movie.Length)].ToUpper();

Thank you for immediate response! Have a nice day.




Aucun commentaire:

Enregistrer un commentaire