jeudi 24 septembre 2020

Randomly generate a specific amount of strings from a List c#

I may not know how to search for a solution properly yet but I could not find anything related to the thing I got stuck on below:

I have a List of strings containing 21 words

public static List<string> LevelOneWords = new List<string> { "As", "If", "Go", "Do", "So", "No", "Up", "Hi", "Me", "Be", "Ah", "An", "Aw", "Is", "Ok", "At", "We", "Am", "Ab", "Ex", "It"};

How do I go on about generating a specific amount of these following a user decision?

Because rand.Next(LevelOneWords.Count) only lets you generate random words from the amount available in the list.

But say I wanted to generate 50 instances?

To put you in the picture, this is a Typer Shark kind of game and in the training session, I want the user to have the freedom to choose how much words should be generated.

Thanking you in advance since I am new to programming and I find StackOverFlow's community very helpful!




Aucun commentaire:

Enregistrer un commentaire