βœ… Having to press <return> twice?

namespace Calculator.View
{
public class InputHandler
{
// Either zeroinputargument() is called or twoinputarguments(string[] input) is used. Based on if arguments for main was 0 or 2.
public static void zeroinputargument()
{
Console.WriteLine("Enter an RPN expression <return> (empty string = exit):\n");
string text = Console.ReadLine();
// If the input from the user is just an "Enter" it will terminate the program.
if (text == string.Empty)
{
System.Environment.Exit(1);
}
CalculationHandler.zeroinput(text);
}
namespace Calculator.View
{
public class InputHandler
{
// Either zeroinputargument() is called or twoinputarguments(string[] input) is used. Based on if arguments for main was 0 or 2.
public static void zeroinputargument()
{
Console.WriteLine("Enter an RPN expression <return> (empty string = exit):\n");
string text = Console.ReadLine();
// If the input from the user is just an "Enter" it will terminate the program.
if (text == string.Empty)
{
System.Environment.Exit(1);
}
CalculationHandler.zeroinput(text);
}
Is there a reason for why i have to press <return> in the console twice for the program to exit?
3 Replies
Merineth πŸ‡ΈπŸ‡ͺ
It does the Console.WriteLine correctly. and then it waits for input from the user but i have to press enter twice for the program to go into the if and close the program I genuinely have no idea why that is the case What's worse is that i can press Enter then on the next row i can type anything followed by enter and it doesn't enter the if statement at all?!
Kuinox
Kuinoxβ€’2mo ago
We dont have the full code, so it's hard to pinpoint the reason. I suggest to use the debugger and press F10 after .Exit(1).
You can also "break all" to see where the thread is waiting.
Visual Studio open a console that closes when you press enter, that's convenient because it doesn't reopen a console every time. That's maybe one of your return.
Then, you can have events handler that do stuff when your program exit, maybe you plugged in code that does that ?
Merineth πŸ‡ΈπŸ‡ͺ
oh right it might just be Visual Studios own like you mentioned I'll leave it as it is then :p thanks !!
Want results from more Discord servers?
Add your server