是否有人可以解决此if语句

时间:2020-05-28 21:53:45

标签: c#

static void Main(string[] args)
{
    string name01;
    string name02;

    Console.WriteLine("Welcome to Choice RPG! <press enter to start your adventure>");
    Console.ReadKey();
    Console.WriteLine("Enter your Adventurers name! <press enter to continue>");
    name01 = Convert.ToString(Console.ReadLine());
    Console.WriteLine(name01 + "! come on, you can think of a better name than that can't you? <press enter to continue>");
    Console.ReadKey();
    Console.WriteLine("Enter your Adventurers name! <press enter to continue>");
    name02 = Convert.ToString(Console.ReadLine());

    if (name02 == name01)
    {
        Console.WriteLine("Wow, i guess you really like that name huh, fine.");
    }
    else
    {
        Console.WriteLine("Now thats more like it!");
    }
}

这是我的第一个总体编程项目。我正在制作一个RPG游戏,您可以在其中选择自己的冒险经历,这是针对用户的游戏名称的。

一切正常,直到if语句(此cmd刚刚关闭)为止。如果有人有任何解决办法,请告诉我。

1 个答案:

答案 0 :(得分:2)

代码对我来说不错,请尝试添加:

Console.WriteLine("Press <ENTER> to exit");
Console.Readline();
最后,请

查看您要显示的消息是否在应用程序退出和关闭之前实际显示。我的猜测是您正在Visual Studio中运行,并且会显示消息,但是执行窗口关闭得如此之快,您看不到它。

相关问题