So my general question is: is there a way to refer to an old random instance after declaring a new one?
First, the following is the code that I'm currently using.
This is the list I created:
Random p1rnd = new Random();
List<string> p1list = new List<string>();
p1list.Add("A");
p1list.Add("B");
p1list.Add("C");
p1list.Add("D");
p1list.Add("E");
p1list.Add("F");
p1list.Add("G");
p1list.Add("H");
p1list.Add("I");
p1list.Add("J");
int p1r = p1rnd.Next(p1list.Count);
This is the block of code where I used the list, and is what I'm currently having an issue with:
Console.WriteLine("\nWhat would you like to say?");
Console.Write("A. ");
p1r = p1rnd.Next(p1list.Count); //CHOICE A
Console.Write(p1list[p1r]);
Console.Write("B. ");
p1r = p1rnd.Next(p1list.Count); //CHOICE B
Console.Write(p1list[p1r]);
Console.Write("C. ");
p1r = p1rnd.Next(p1list.Count); //CHOICE C
Console.Write(p1list[p1r]);
p1choiceA = Console.ReadLine();
Basically, I'm planning to use if-else statements to remove the choices. However, I don't know how to phrase my condition.
if ( ) // SHOULD BE CHOICE A
{
p1list.Remove( )
}
else if ( ) // SHOULD BE CHOICE B
{
p1list.Remove( )
}
else if ( ) // SHOULD BE CHOICE C
{
p1list.Remove( )
}
Typically, I would use p1list[p1r]
. But, given that I created new random instances for each, I don't know what to put anymore. How would I refer to the instance used in CHOICE A and B? Thanks.