同じ文字列変数の複数のエントリをループできる方法があるかどうか興味がありますか? 基本的に、プレイヤー名の複数のエントリを For ループに出力したいのですが、頭がおかしくなり、これまでに書いた単純なコードを while で拡張する方法に困惑しています。 -ループ。
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();
}
}