I created a player class and made a array from that class for my menu driven player system I am trying to use my GetChar method to keep displaying the prompt and reading whatever the user typed on the keyboard until Char.TryParse can convert the input to an char But I keep getting the error Cannot complicity convert type char to string when I call my GetChar method.
Any help would be appreciated
static void ProcessCreate(Int32 number, String firstName, String lastName, Int32 goals,
Int32 assists, Player[] players, ref Int32 playerCount, Int32 MAXPLAYERS)
{
if (playerCount < MAXPLAYERS)
{
number = IOConsole.GetInt32("\nCreate Player: please enter the player's number");
if (GetPlayerIndex(number, firstName, lastName, goals, assists, players, ref playerCount) == -1)
{
firstName = IOConsole.GetChar("\nCreate Player: please enter the player's First Name");
lastName = IOConsole.GetChar("\nCreate Player: please enter the player's Last Name");
goals = IOConsole.GetInt32("\nCreate Player: please enter the player's goals");
Int32.Parse(Console.ReadLine());
assists = IOConsole.GetInt32("\nCreate Player: please enter the player's assists");
InsertPlayer(number, firstName, lastName, goals, assists, players, ref playerCount);
Console.WriteLine("\n{0,7} {1,-20}{2, -20}{3,8}{4,8}{5,8}\n", "Number", "First Name", "Last Name", "Goals", " Assists", "Points");
for (Int32 player = 0; player < playerCount; player++)
Console.WriteLine("{0,7} {1,-20}{2, -20}{3,8}{4,8}{5,8}",
players[player].Number, players[player].FirstName, players[player].LastName,
players[player].Goals, players[player].Assists, players[player].Points());
Console.WriteLine();
}
else
Console.WriteLine("\nCreate Player: the player number already exists");
}
else
Console.WriteLine("\nCreate Player: the player roster is already full");
}
Here is my get char method
public static char GetChar(String prompt)
{
char validChar;
while (!Char.TryParse(Console.ReadLine(), out validChar))
{
Console.WriteLine("Invalid entery - try again.");
Console.Write(prompt);
}
return validChar;
}