I'm a beginner to programming and have this task I want to complete.
Task at hand:
Write a program where the user is allowed to enter their name, then (in a while loop) the program prompts the user to type enter your name again. If the user fills in the same name as the first time, the program ends (break), otherwise the program continues to ask.
I tried to use this code that I wrote:
Console.Write("Enter your name: ");
string name = "";
while (name != "")
{
Console.Write("Enter your name again: ");
name = Console.ReadLine();
if (name != "")
{
break;
}
}
Console.ReadLine()after you've told the user you're asking for their name again... they haven't entered it once!