如果密码框为空。它显示Passwords created Successfully
. 我不知道我在这里做错了什么。但是,如果输入的密码不匹配,如果条件按代码工作。验证 null 时出错。
代码;
void savePassword(object sender, RoutedEventArgs e)
{
string password1 = createPassword.Password;
string password2 = repeatPassword.Password;
if (password1 != null || password2 != null)
{
if (password1 == password2)
{
MessageBox.Show("Password Created Successfully");
}
else
{
MessageBox.Show("Passwords did not match.");
}
}
else
{
MessageBox.Show("Both fields are required");
}
}