Reputation: 55
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
}
Can someone help me to fix this, as I cannot see what where I am going wrong...
Upvotes: 3
Views: 809
Reputation: 460058
Player
is the type/struct, players
the Player[]
, so use this:
players[i].Name = Console.ReadLine(); // instead of Player[i]
Upvotes: 8