如何在控制台应用程序中添加C#登录尝试循环?

如何在控制台应用程序中添加C#登录尝试循环?

问题描述:

我是这种语言的新手,我尝试了一些东西,但无法弄清楚如何设置登录循环以最大使用登录尝试次数.的3倍.有人可以帮我吗?

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?

    static void Main(string[] args)
    {

        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();
        }

        else
        Console.Clear();
        Console.WriteLine("Helaas, gebruikersnaam of wachtwoord niet correct.");

    }
  }

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("....");
}

}