我试图"0"使用以下代码查看文本框是否为空.
我希望我可以使用!运算符,IsNulorEmpty但似乎它没有做我想要的.在一条线上有一个简单的方法吗?
if (!String.IsNullOrEmpty(MyTextbox.Text) || MyTextbox.Text != "0")
{
//string is either null, empty or 0
}
else
{
//string has a value
}
Run Code Online (Sandbox Code Playgroud)
E-B*_*Bat 12
代码正在执行您编写的内容,但您对操作员评估感到困惑:
if (string.IsNullOrEmpty(MyTextbox.Text) || MyTextbox.Text == "0")
{
//string is either null, empty or 0
}
else
{
//string has a value
}
Run Code Online (Sandbox Code Playgroud)