Jump to content

Im following the C# guide and i started today, but i dont understand why this code doesnt work.


Guest

Recommended Posts

using System;

namespace ReadlinPractice
{
    class Program
    {
        static void Main(string[] args)
        {
            string passWord = "pass123";
            string userName = "user";
            Console.WriteLine("Please enter your username below!");
            string userName2 = Console.ReadLine();
            if (userName != userName2);
            { 
                Console.WriteLine("User not found! Please re-enter your username");
                string userName3 = Console.ReadLine();
                string result = (userName3 != userName) ? "Blocked, please try again in 5 minutes." : "Error, please restart the program.";
                Console.WriteLine(result);
            }
            else {
                Console.WriteLine("User found. Please enter your password.");
                string passWord2 = Console.ReadLine();
                if (passWord != passWord2)
                { 
                    Console.WriteLine("Wrong password entered, please try again in 5 minutes");
                }
                else {
                    Console.WriteLine("Congrats, successfully logged in!");
                     }
            }
        }
    }
}

How can I fix this??

inkorrektkod.png

Link to comment
Share on other sites

The problem is the semi-colon at the end of your if() statement on line 13. Your syntax highlighter has been kind enough to underline it in green to indicate that you probably don't want it there.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...