I'm am making a simple hangman game that runs in the console. I created a method that selects random words from a list to be later implemented as the answer. I created this method to do it:
public static string GetWord()
{
Random random = new Random();
string[] words = new string[5]{"a", "b", "c", "d", "e"};
return words[random.Next(5)];
}
And I tested the method by looping the method 100 times with a for loop:
static void Man(string[] args)
{
for(int i = 0; i <101; i++)
{
Console.WriteLine(GetWord());
}
}
I expect to get a random set of letters as output. However, when I run the program, this is not the case. Instead, I get something akin to:
d d d d d d d d d d d d d
d d d c c c c e e e e e
e d d d d d a a
a a a a a a a b b b b b b b b b b
b c c c c e e e e e e e e d d d d a a a a a a a a a e e e b b b b b b b b d d d d d c c c c c c e
Is it something I'm doing wrong? If so, what can I do to fix this? Thank you in advance