Как организовать проверку пароля с учетом регистра символов - C#
Формулировка задачи:
private void button1_Click(object sender, EventArgs e)
{
try
{
if (textBox1.Text != "Админ" && textBox2.Text != "068421034")
if (textBox1.Text != "Пользователь" && textBox2.Text != "068116150")
{
textBox1.Text = "";
textBox2.Text = "";
MessageBox.Show("Попробуйте еще раз!!!", "Неверный логин или пароль", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
if (textBox1.Text == "Админ" && textBox2.Text == "068421034")
{
Form3 f3 = new Form3();
f3.Show();
this.Close();
}
if (textBox1.Text == "Пользователь" && textBox2.Text == "068116150")
{
Form4 f4 = new Form4();
f4.Show();
this.Close();
}
}
catch
{
MessageBox.Show("Попробуйте еще раз!!!", "Неверный логин или пароль", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
}Решение задачи: «Как организовать проверку пароля с учетом регистра символов»
textual
Листинг программы
private void button1_Click(object sender, EventArgs e)
{
try
{
if (textBox1.Text != "Админ" && textBox2.Text != "068421034")
if (textBox1.Text != "Пользователь" && textBox2.Text != "068116150")
{
textBox1.Text = "";
textBox2.Text = "";
MessageBox.Show("Попробуйте еще раз!!!", "Неверный логин или пароль", MessageBoxButtons.OK, MessageBoxIcon.Stop);
return;
}
if (textBox1.Text == "Админ" && textBox2.Text == "068421034")
{
Form f3 = new Form();
f3.Show();
this.Hide(); return;
}
if (textBox1.Text == "Пользователь" && textBox2.Text == "068116150")
{
Form f4 = new Form();
f4.Show();
this.Hide(); return;
}
throw new SystemException();
}
catch
{
MessageBox.Show("Попробуйте еще раз!!!", "Неверный логин или пароль", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
}