بالإمكان عمله بطريقة ابسط وب loop واحد فقط. وايضاً انصح بإستخدام switch في حالة تعدد الاختيارات كما هو بسؤالك. سيكون افضل.
List<int> inputList = new List<int>();
decimal total = 0.0M;
int userChoice = 0;
for (int x = 0; x < 10; x++)
{
Console.Write("Enter number " + (x + 1) + " :");
inputList.Add(Convert.ToInt32(Console.ReadLine()));
total += inputList[x];
}
Console.WriteLine();
Console.WriteLine("Choose what you want to do:");
Console.WriteLine(" 1. Show the largest number");
Console.WriteLine(" 2. Show the smallest number");
Console.WriteLine(" 3. Show the mean to one decimal");
Console.WriteLine(" 4. Display all input numbers");
Console.WriteLine(" 5. Finish this program");
userChoice = Convert.ToInt32(Console.ReadLine());
switch (userChoice)
{
case 1: // 1. Show the largest number
Console.WriteLine("Max : \t" + inputList.Max());
break;
case 2: // 2. Show the smallest number
Console.WriteLine("Min : \t" + inputList.Min());
break;
case 3: // 3. Show the mean to one decimal
Console.WriteLine("Mean : \t" + (total / inputList.Count));
break;
case 4: // 4. Display all input numbers
string allNumbers = string.Join(Environment.NewLine, inputList);
Console.WriteLine(allNumbers);
break;
case 5: // 5. Finish this program
Environment.Exit(0);
break;
}
// Keep The console open
Console.WriteLine();
Console.WriteLine("Press any key to exit ...");
Console.ReadLine();