我很好奇是否有一种方法可以循环同一个字符串变量的多个条目?基本上,我想将玩家姓名的多个条目打印到一个 For 循环中,但是我有一个脑残,我很难理解如何扩展我到目前为止编写的简单代码段-环形。
class Program
{
static void Main(string[] args)
{
string choice = "y";
string player_name = "";
while (choice == "y")
{
Console.WriteLine("Enter the players name: ");
player_name = Console.ReadLine();
Console.WriteLine("Would you like to enter another player? y/n");
choice = Console.ReadLine();
}
Console.WriteLine(player_name);
Console.ReadLine();
}
}