char typeClient = ' ';
bool clientValide = false;
while (!clientValide)
{
Console.WriteLine("\nEntrez le type d'employé (c ou g) : ");
clientValide = char.TryParse(Console.ReadLine(), out typeClient);
if (clientValide)
typeClient = 'c';
}
I'd like to make it so it doesn't exit the while unless the char is 'g' or 'c' help ! :)
You're really close, I think something like this will work well for you:
basically it reads the input into the
typeClient
variable when the user enters something so the loop will continue until they enterg
orc
.Is you use
Console.ReadLine
, the user has to press Enter after pressing c or g. UseReadKey
instead so that the response is instantaneous:You can use ConsoleKeyInfo with Console.ReadKey() :
Et puis après vous ferez votre bloque IF comme bon vous semblera pour votre type de client ;)