Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Beginner Question

$
0
0

Hello. I'm doing the online microsoft virtual academy to learn C#. I'd like to get a little practice using what I learned by creating a little console "story". I am unsure what is wrong here.

Console.WriteLine("Hello eager Adventurer! Are you ready for your journey? Type Yes or No to continue");
            string a = Console.ReadLine();

            if (a == "Yes")
            {
                Console.WriteLine("Very well! Make a choice!");
                Console.WriteLine("(1) You journey to the land of mountains");
                Console.WriteLine("(2) You journey through the shadowy forest");
                
                if (a == "1")
                {
                    Console.WriteLine("You travel to the treachorous ands of Khangu. By speaking to a few locals you learn that an ancient treasure exists upon the summit of the greatest mountain");
                    
                }
                if (a == "2")
                {
                    Console.WriteLine("You travel to the forest");
                }
            }
            Console.ReadLine();  

Yea, it's a little silly but a fun little project. The program gets the answer "Yes" and then moves on to the three Console.WriteLine lines. When I press 1 the console closes. I am unsure what I did wrong.


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>