How to add c# login attempts loop in console application?

前端 未结 3 2114
无人及你
无人及你 2021-01-23 06:13

I\'m new to this language, I tried things but couldn\'t figure out how to set a login loop to use login attemps with a max. of 3 times. Could someone help me out?



        
3条回答
  •  隐瞒了意图╮
    2021-01-23 06:44

    static void Main(string[] args)
    {
        for (int i=0; i<3; i++) 
        {
            Console.WriteLine("Status: " + status.Onaangemeld);
            Console.WriteLine("Welkom, typ hieronder het gebruikersnaam:");
            string Naam = Console.ReadLine();
    
            Console.WriteLine("Vul hieronder het wachtwoord in:");
            string Wachtwoord = Console.ReadLine();
    
            if (Naam == "gebruiker" && Wachtwoord == "SHARPSOUND")
            {
                Console.Clear();
                Console.WriteLine("Status: " + status.Ingelogd);
                Console.WriteLine("Welkom bij SoundSharp {0}!", Naam);
                Console.ReadLine();
                break;
            }
    
    
            Console.Clear();
            Console.WriteLine("Helaas, gebruikersnaam of wachtwoord niet correct.");
    
        }
    
        Console.Clear();
        Console.WriteLine("....");
    }
    

    }

提交回复
热议问题