public void Login()
{
//Admin login temp
if (txtusername.Text == "admin" && txtpassword.Text == "admin123")
{
Form mainmenu = new frmmainmenu();
Useraccounts.LoggedInUsername = txtusername.Text;
this.Hide();
mainmenu.Show();
return;
Hata, kullanıcı hesapları olarak ulaşılamaz kod görüntülüyor burada değişken kullanıcı 6 kullanıcı hesaplarını detaylandırma hesapları ve LoggedInUsername için sınıf var olanOturum açma ekranı için bir if deyimi içinde ulaşılamaz kod algılandı mı?
//Make new object of useraccounts class for logging in
**Useraccounts** Loginattempt = new Useraccounts();
//Retrieve the number of accounts there are to run the loop the appropriate number of times
int NoOfAccounts = Loginattempt.Username.Length;
for (int i = 0; i <= NoOfAccounts; i++)
{
try
{
//Checking the username against the class & check if password matches
if (txtusername.Text == Loginattempt.Username[i])
{
if (txtpassword.Text == Loginattempt.Password[i])
{
Form Mainmenu = new frmmainmenu();
Useraccounts.LoggedInUsername = txtusername.Text;
this.Hide();
Mainmenu.Show();
return;
}
}
}
catch
{
//If the username cannot be found do nothing.
}
}
{
MessageBox.Show("Incorrect username or password.");
}
}
}
}
}
Bu bir yöntem mi? Önceki satırda 'dönmek 'diyorsun. – Lee
Kodun tam ortasına bu gibi bir metin koymak yardım istemek için iyi bir fikir değildir. Bunun bir tek yöntem olduğunu ve Lee'nin doğru olduğuna eminim. –