char typeClient = \' \';
bool clientValide = false;
while (!clientValide)
{
Console.WriteLine(\"\\nEntrez le type d\'employé (c ou g) : \");
clientValide = cha
Is you use Console.ReadLine
, the user has to press Enter after pressing c or g. Use ReadKey
instead so that the response is instantaneous:
bool valid = false;
while (!valid)
{
Console.WriteLine("\nEntrez le type d'employé (c ou g) : ");
var key = Console.ReadKey();
switch (char.ToLower(key.KeyChar))
{
case 'c':
// your processing
valid = true;
break;
case 'g':
// your processing
valid = true;
break;
default:
Console.WriteLine("Invalid. Please try again.");
break;
}
}