或者:
var strings = new List<string>() {"one", "two", "thee", .... "n"};
if(strings.Contains(textBox1.Text)){
}
Run Code Online (Sandbox Code Playgroud)
您不能以我怀疑您正在尝试的方式组合运算符:
if (textBox1.Text == "one" || "two")
Run Code Online (Sandbox Code Playgroud)
您需要按如下方式限定每个条件:
if (textBox1.Text == "one" || textBox1.Text == "two")
Run Code Online (Sandbox Code Playgroud)
有很多方法可以使这更容易,请参阅此问题的答案以获取替代方法
| 归档时间: |
|
| 查看次数: |
15618 次 |
| 最近记录: |