我有两个文本框。如果 textbox.text 中的 1 个为空,则 MessageBox 将显示以提示用户他们没有完整输入字段。然而它不起作用......
这是代码:
private void tab1nextButton_Click(object sender, RoutedEventArgs e)
{
if ((AntcbatchpathTextBox.Text == null) || (MasterbuildpropertiespathTextBox.Text == null))
{
System.Windows.MessageBox.Show("You have not specified the paths completely!");
}
else
{
Tabitem2.Visibility = Visibility.Visible;
Tabcontrol1.SelectedIndex = 1;
}
}
我尝试添加断点来检查即时值。当其中一个Textbox.Text为空时,立即值分别为“”。我的代码有什么问题吗?
最佳答案
尝试 string.IsNullOrEmpty(AntcbatchpathTextBox.Text)
关于c# - 如果其他字符串为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5075907/