user2007843
user2007843

Reputation: 609

Program isn't stopping for user input

When I run my program it just runs straight through and doesn't allow me to enter user inputs.

Here is my main function

[STAThread]
static void Main()
{
    valueCalculation(validateX(), validateY(), validateZ());
}

And here is my validateX function

public static String validateX()
{
    Console.WriteLine("Enter your X value: ");
    string x = null;
    do
    {
        x = Console.ReadLine();

        //do stuff
    }
    while(x != null);

    return x;
}

Upvotes: 0

Views: 113

Answers (1)

Marc Gravell
Marc Gravell

Reputation: 1064114

The presence of:

[STAThread]

Suggests that this was once a winforms application, which indeed would return null for Console.ReadLine. Change it to be a console application. If this is in VS2013, right click on the project name; Properties => Application => Output type.

Upvotes: 11

Related Questions