Suppose you need to get strings from user input. In a console application, the desired code is straightforward:
string input1 = Console.ReadLine();
string input2 = Console.ReadLine();
However, in my Windows Forms application, I’m working with a Multiline TextBox. I want to capture strings when the user presses the Enter key, with each line separated by a newline.
I’m curious if there’s an Async/Await solution that allows me to handle the KeyPressed event and return user inputs. Ideally, I’d like to achieve something like this:
string input1 = await GetUserInputAsync();
string input2 = await GetUserInputAsync();