I have an assignment in my C# class that I am confused on. Here is the assignment below. My question is how to implement the carriage return? It seems like using /r resets to the beginning of the line... I was going to use string.empty in a while loop, but I can't tell by the instructions if there is a way to get the desired result by using the carriage return. I feel like I am looking way to into this. Any thoughts?
Let's take a moment to get our program to do something. Modify your program to:
● Prompt the user for their name
● Store the input string into a variable named str01.
● Output a greeting to the console using the string stored in str01. (ex. "Hello, Ethel!")
● Keep prompting the user to enter a name.
● If they enter an empty string (a simple carriage return), then drop out of the loop with an appropriate message (ex. "See you next time!").
class App01
{
static void Main(string[] args)
{
string str01;
for(;;)
{
Console.Write ("Enter your name -");
str01 = Console.ReadLine();
Console.WriteLine("Hello '{0}'", str01);
}
}
}
while loopthat should do the same actions, until thestr01 variableis eqaul to acarriage return. - Ryan WilsonReadLine(). Run and pressEnter. Look at the value ofstr01. - MikeH