use*_*553 3 c# variables types
struct Player
{
public string Name;
public int X;
public int Y;
}
static Player[] players = new Player[amountofPlayers];
for (int i = 1; i < amountofPlayers; i = i + 1)
{
int displayNumber = i + 1;
Console.Write("Please enter the name of player " + displayNumber + ": ");
Player[i].Name = Console.ReadLine(); // The error is here
}
Run Code Online (Sandbox Code Playgroud)
有人可以帮我解决这个问题吗,因为我看不出我哪里错了...
Player
是类型/结构,players
在Player[]
,所以使用此:
players[i].Name = Console.ReadLine(); // instead of Player[i]
Run Code Online (Sandbox Code Playgroud)