Привет Я создаю программу, которая содержит три массива один для фамилии людей, один для очков и один для номера игрока, теперь у меня есть все массивы и все сделано, но я не уверен, как как я собираюсь удалить запись для нескольких массивов. до сих пор это то, что у меня есть для моего метода удаления игрока. Некоторые рекомендации в правильном направлении действительно поможет, пожалуйста, и спасибоМассивы, как удалить записи в нескольких массивах?
static Int32[] ProcessDelete(Int32[] playerNumbers, String[] playerLastName, Int32[] playerPoints, ref Int32 playerCount)
{
Int32[] newArray = new int[playerNumbers.Length - 1];
int index = 0;
int j = 0;
while (index < playerNumbers.Length)
{
if (index != playerCount)
{
newArray[j] = playerNumbers[index];
j++;
}
index++;
}
return newArray;
}
static void DeletePlayer(Int32[] playerNumbers, String[] playerLastName, Int32[] playerPoints, ref Int32 playerCount, Int32 MAXPLAYERS)
{
int player;// Player number to delete
int playerindex;//index of the player number in Array
if (playerCount < MAXPLAYERS)
{
player = GetPositiveInteger("\nDelete Player: please enter the player's number");
playerindex = GetPlayerIndex(player, playerNumbers, playerCount);
if (playerindex != -1)
{
{
Console.WriteLine("\nDelete Player: Number - {0}, Name - {1}, Points - {2}", playerNumbers[playerindex], playerLastName[playerindex], playerPoints[playerindex]);
Console.WriteLine("Succesfully Deleted");
Console.WriteLine();
}
}
else
Console.WriteLine("\nDelete Player: player not found");
}
else
Console.WriteLine("\nDelete Player: the roster is empty");
}
}
}
Может быть, массив не правильный тип для вашего случая. –
Не используйте для этого массивы, определите класс, который выражает соответствующие данные для игрока. –
класс 'Player' будет содержать связанную информацию вместе, а в списке будет проще управлять несколькими игроками –
Plutonix