Anyone Familiar with C#?

Started by Emperor Wilbers, April 18, 2014, 10:02:19 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Emperor Wilbers

I'm getting back into coding (even though I didn't make it far when I first started) but instead of doing C++ or whatever I did before I'm doing C#, and I ran into a problem and the editor isn't accepting my code, even though it looks EXACTLY the same as the tutorial I am watching! Even if you aren't familiar with it it's very basic, so I hope someone can help anyways.

namespace Decisions
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Would you prefer what is behind door number 1, 2, or 3?");
            string userValue = Console.ReadLine();
            if (userValue == "1")
            {
                Console.WriteLine("You won a new car!");
                Console.ReadLine();
            }
            else if (userValue == "2")
            {
                Console.WriteLine("You won a new boat!");
                Console.ReadLine();
            }
            else if (userValue == "3");
            {
                Console.WriteLine("You won a new cat!");
                Console.ReadLine();
            }
            else
            {
                Console.WriteLine("Sorry, we didn't understand. You lose!");
                Console.ReadLine();
            }

        }
    }
}


For some reason it says that "else" is an invalid expression term and it comes up with three errors and one warning:
-Warning   1 Possible mistaken empty statement   
-Error 2 Invalid expression term 'else'
-Error 3 ; expected
-Error 4 Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement

When I Start it it works for 1, 2, and 3, but when I type in any other value it still gives one of the responses for if 3 which is You won a new cat. It only puts red squiggles under "else" and the bracket just above it, so, idk what to do, lol. I just wanna figure it out so I don't mess up later on.

Grimston

Ah C# thats what DRPG is written using.

You have a semicolon after the if else statement

else if (userValue == "3");

Edit: what editor/IDE are you using?
I'm a suicidal planet and I'm aiming at the sun,
All the gravity inside me will give way to a beautiful calm,
If you're gravitating to me, now's the time to turn and run,
I see a raging ball of fire, burning life lines in my palms