0

提供第一个输入后,我必须按两次回车。我在代码中做错了什么:

public static void Ifcondition()
{            
    string answer,value1;
    Console.Clear();
    Console.WriteLine("Would you like to enter your Name");
    answer = Console.ReadLine();             
    if (answer == "Yes")
    {               
        Console.WriteLine("Great!!! - Please enter your Name:");
        value1 = Console.ReadLine();
        Console.WriteLine("Have a Great Day - {0}", value1);                
    }
    else
    {
        Console.WriteLine("Bye!!!");
    }
    Console.ReadKey();
}
4

1 回答 1

0

在您的代码中:

    public static void Ifcondition()
    {            
        string answer,value1;
        Console.Clear();
        Console.WriteLine("Would you like to enter your Name");
   1     answer = Console.ReadLine();             
        if (answer == "Yes")
        {               
            Console.WriteLine("Great!!! - Please enter your Name:");
   2        value1 = Console.ReadLine();
            Console.WriteLine("Have a Great Day - {0}", value1);                
        }
        else
        {
            Console.WriteLine("Bye!!!");
        }
   3     Console.ReadKey()};

您有 3 个需要用户操作的位置。在(1)之后,如果答案==“是”,逻辑将转到(2)并要求输入,然后下降到(3)并再次要求输入。如果答案不是 =="Yes",则属于 (3)。在“祝你有美好的一天”信息之后移动 (3)。

于 2013-11-14T13:22:52.890 回答