I'm trying to make a rock, paper, scissors application through C#. This part is supposed to pick a random value from enum (rock/paper/scissors), and it does the job but it picks random value twice. What is the problem?
Random random = new Random();
Type type = typeof(ComInput);
Array values = type.GetEnumValues();
//Array values = Enum.GetValues(type):
for (int i = 0; i < 2; ++i)
{
int index = random.Next(values.Length);
ComInput value = (ComInput)values.GetValue(index);
Console.WriteLine("제 선택은");
//Console.ReadLine();
Console.WriteLine(value);
}
Aucun commentaire:
Enregistrer un commentaire