I have to: 1. Write an information to user. 2. Read the typed message. 3. If message is empty then close application.
It is very simple to just read the user input in following way and process it:
static void Main(string[] args)
{
string line;
Console.WriteLine(message);
while ((line = Console.ReadLine()).Length > 0)
{
// process line here and return output to console
Console.WriteLine(message);
}
}
But as I am a purist I want to omit all repeated statements (like "Console.WriteLine(message);" in this example). I have already tried the do{..}while(..) loop with no success (repeated Console.ReadLine() statements).
Do you have any smart idea how to accomplish this task?