Jump to content
Sign in to follow this  
syzerchas

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

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

Share this post


Link to post
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.

  • Thanks 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...