1
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!");
    }
}

This is my first project with programming in general. I am making an RPG game in which you choose your adventure and this is for the user's ingame name.

Everything works up until the if statement (after that the cmd just closes). If anyone has any ideas to fix it please tell me.

Enigmativity
  • 97,521
  • 11
  • 78
  • 153
MrKronic
  • 11
  • 1

1 Answers1

2

Code looks OK to me, try adding:

Console.WriteLine("Press <ENTER> to exit");
Console.Readline();

at the end to see if the message you want to show, actually shows before the application exits and closes. My guess is you are running in Visual Studio, and the message prints, but then the execution window closes so fast you don't see it.

E.J. Brennan
  • 42,120
  • 6
  • 74
  • 108