I am currently looking for a solution for this c# console application function
I tried searching for a method for creating a while loop that can terminate for the co
You can do the following
var options = new Dictionary {
{1, () => {
//opt 1 code
}},
{2, () => {
//opt 2 code
}},
{3, () => {
//opt 3 code
}},
{4, () => {
//opt 4 code
}}
};
Console.WriteLine("Please enter you choice:");
int P1Choice;
while (!(int.TryParse(Console.ReadLine(), out P1Choice) && options.ContainsKey(P1Choice)))
{
Console.WriteLine("Input Invalid, Please press the number from the corresponding choices to try again:");
}
options[P1Choice]();