You have to create a variable before the loop if you want to use it in a loop condition. But why do you need
userSecondInput
, it has never been used outside of the loop. You just want to capture none-empty input from the user, just use
userInput
will do. Try this
if (string.IsNullOrEmpty(userInput))
{
do
{
Console.WriteLine("invalid value! Please Enter Your name: ");
userInput = Console.ReadLine();
}
while (string.IsNullOrEmpty(userInput));
}