lundi 9 octobre 2017

Why is my if-statement partly not working?

I just started learning C#. I am making a login system but the else statement doesn't work. I tried a lot of things but the problem is still not solved. Can anybody help me?

class Program
{
    static void Main(string[] args)

    {
        Console.WriteLine("Welcome");
        Console.Write("USERNAME: ");
        string name = Console.ReadLine();


            Console.Write("PASSWORD: ");
         Console.ForegroundColor = ConsoleColor.Black;
             string strPassword = Console.ReadLine();
            string strTPassword = "password";
            Console.WriteLine();


        if (strPassword == strTPassword)
        {
            Console.ForegroundColor = ConsoleColor.White;
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Done");
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("Welcome " + name + "!");
        }
        else
        {
            Console.WriteLine("Bad username!");
            Console.ReadLine();
        }

    }




    }

Aucun commentaire:

Enregistrer un commentaire