非常基本,但我正在创建一个游戏,我将在游戏中有 2 到 4 个玩家我需要知道如何询问用户会有多少玩家,然后将这个数量存储在我的数组中以供以后使用?!
这是我到目前为止写的
{
int NumberofPlayers;
{
do
{
Console.WriteLine("Please enter number of players (2-4): ");
String StringNumberOfPlayers = Console.ReadLine();
NumberofPlayers = int.Parse(StringNumberOfPlayers);
}
while (NumberofPlayers > 4 || NumberofPlayers < 2);
}
// need get the number of players and set the required elements in
// playerPositions to 0 on the board
}
static int [] PlayerPositions = new int [4];
static void Main()
{
ResetGame();
}
}
}