帮看下 这么写对不 超简单 B1 或者B2 不得为空 if (B1.Text != "" || B2.Text != "" )B1 和B2 不得为空 if (B1.Text != "" && B2.Text != "" )这么写对吗 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 对的对于textBox来说空就""或string.Empty但对于普通字符串要判断其是否为null更好的写法:if (!string.IsNullOrEmpty(B1.Text) ||! string.IsNullOrEmpty(B2.Text ) ) 对的!或者你也可以这样写!if (!string.IsNullOrEmpty(B1.Text) ||! string.IsNullOrEmpty(B2.Text ) )( 对的,B1.Text正常是某个控件的text值,所以也不需要考虑NULL值,默认就是空值。要对自己有自信,这样以后才能学好 if (!string.IsNullOrEmpty(B1.Text) ||! string.IsNullOrEmpty(B2.Text ) ) if (this.textBox1.Text == "" || this.textBox2.Text == "") { MessageBox.Show("班级编号和名称不能为空!"); } C# codeif (this.textBox1.Text == "" || this.textBox2.Text == "") { MessageBox.Show("输入的不能为空,请重新输入!"); } 该说的都说了 另外 你发现自己写的东西有问题 你可以写个实例测试下 调试你要学会 这样自己都能找到自己的代码的bug的 地图划分区域问题 调查下,现在做个网站一般需要多少钱?可以根据网站的性质,说详细点。 网通的用户进来帮看一下 NAT穿透问题 在问一个多线程的问题,如何管理线程 关于Tree控件的使用 请诸位解释下c#2.0的迭代器,谢谢 怎么把上下文传到下一个网页? 求救.不知原因何在 开两帖200分,高手来拿 避免内存泄露 c# 控件停靠窗体
对于textBox来说空就""或string.Empty
但对于普通字符串要判断其是否为null
更好的写法:
if (!string.IsNullOrEmpty(B1.Text) ||! string.IsNullOrEmpty(B2.Text ) )
if (!string.IsNullOrEmpty(B1.Text) ||! string.IsNullOrEmpty(B2.Text ) )(
{
MessageBox.Show("班级编号和名称不能为空!");
}
{
MessageBox.Show("输入的不能为空,请重新输入!");
}