C # как предотвратить использование специальных символов
Hello, I just created this condition to block special characters. it works, but can we make it simpler? Who can bring me a better solution?
Что я уже пробовал:
private void textbox1_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == '>' || e.KeyChar == '<' || e.KeyChar == '@' || e.KeyChar == '{' || e.KeyChar == '}' || e.KeyChar == '[' || e.KeyChar == ']' || e.KeyChar == '#' || e.KeyChar == '&' || e.KeyChar == '(' || e.KeyChar == ']' || e.KeyChar == '/' || e.KeyChar == '|' || e.KeyChar == '*' || e.KeyChar == '-' || e.KeyChar == '+' || e.KeyChar == '$' || e.KeyChar == '%' || e.KeyChar == '~' || e.KeyChar == 92) { e.Handled = true; } }