C# can';不要调用int,即使我公开了它

C# can';不要调用int,即使我公开了它,c#,C#,因此,我有一个名为“Inlogpoging”的登录尝试循环。3次之后,它需要向您发送消息“login limited”。但是我在脚本的结尾有错误,这有什么不对吗 static void Main(string[] args) { for (int inlogpoging = 0; inlogpoging < 3; inlogpoging++) { Console.WriteLine("Status: " + status.Onaangemeld);

因此,我有一个名为“Inlogpoging”的登录尝试循环。3次之后,它需要向您发送消息“login limited”。但是我在脚本的结尾有错误,这有什么不对吗

static void Main(string[] args)
{
    for (int inlogpoging = 0; inlogpoging < 3; inlogpoging++)
    {
        Console.WriteLine("Status: " + status.Onaangemeld);
        Console.Write("Gebruikersnaam:");
        string Naam = Console.ReadLine();

        Console.Write("Wachtwoord:");
        string Wachtwoord = Console.ReadLine();

        if (Naam == "administrator" && 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.");
    }

    if (int inlogpoging == 3); //Right here <--
    {
        Console.Clear();
        Console.WriteLine("Login limited.");
    }
}
static void Main(字符串[]args)
{
对于(int-inlogpoging=0;inlogpoging<3;inlogpoging++)
{
Console.WriteLine(“状态:+Status.onangeld”);
Console.Write(“Gebruikersnaam:”);
字符串Naam=Console.ReadLine();
Console.Write(“Wachtwoord:”);
字符串Wachtwoord=Console.ReadLine();
如果(Naam==“管理员”&&Wachtwoord==“SHARPSOUND”)
{
Console.Clear();
Console.WriteLine(“状态:“+Status.Ingelogd”);
Console.WriteLine(“Welkom bij SoundSharp{0}!”,Naam);
Console.ReadLine();
打破
}
Console.Clear();
Console.WriteLine(“Helaas,wachtwoord niet的gebruikersnaam,正确。”);
}

if(int inlogpoging==3);//就在这里,您在
if
附近有语法错误;
if
中不允许声明,这些声明用于计算条件。而且不需要用
终止它们;
以下代码可能会帮助您:

int inlogpoging = 0;
for (; inlogpoging < 3; inlogpoging++)
    {
        // do the operations here
    }
// change the if as below
if (inlogpoging == 3) 
    {
       Console.Clear();
       Console.WriteLine("Login limited.");
    }
int inlogpoging=0;
对于(;inlogpoging<3;inlogpoging++)
{
//在这里做手术
}
//如下图所示更改if
如果(inlogpoging==3)
{
Console.Clear();
Console.WriteLine(“登录有限”);
}

我认为您的代码不能满足您的要求。 考虑下面的代码,检查注释:

static void Main(string[] args)
      {

        int inlogpoging = 0;//initialize int counter
        while(inlogpoging<3)
        {
          if (inlogpoging == 3) //if equal to 3 then stop loguin process
          {
            Console.Clear();
            Console.WriteLine("Login limited.");
          }
          else {//if not 3 then process loguin
            Console.WriteLine("Status: " + status.Onaangemeld);
            Console.Write("Gebruikersnaam:");
            string Naam = Console.ReadLine();

            Console.Write("Wachtwoord:");
            string Wachtwoord = Console.ReadLine();

           //at this point increment counter
            inlogpoging++;

            if (Naam == "administrator" && Wachtwoord == "SHARPSOUND")
            {
                Console.Clear();
                Console.WriteLine("Status: " + status.Ingelogd);
                Console.WriteLine("Welkom bij SoundSharp {0}!", Naam);
                Console.ReadLine();

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


               //need a exit point
               return 0;
            }
        }
      }
    }
static void Main(字符串[]args)
{
int inlogpoging=0;//初始化int计数器

while(inlogpoging)的语法错误
if(inlogpoging==3)
就足够了,不要放分号there@un-幸运的是,删除单个空行并没有帮助,它会严重损害可读性。这不是一个好的编辑