B1 或者B2 不得为空 
if (B1.Text != "" || B2.Text != "" )
B1 和B2 不得为空 
if (B1.Text != "" && B2.Text != "" )
这么写对吗

解决方案 »

  1.   

    对的
    对于textBox来说空就""或string.Empty
    但对于普通字符串要判断其是否为null
    更好的写法:
    if (!string.IsNullOrEmpty(B1.Text) ||! string.IsNullOrEmpty(B2.Text ) )
      

  2.   

    对的!或者你也可以这样写!
    if (!string.IsNullOrEmpty(B1.Text) ||! string.IsNullOrEmpty(B2.Text ) )(
      

  3.   

    对的,B1.Text正常是某个控件的text值,所以也不需要考虑NULL值,默认就是空值。要对自己有自信,这样以后才能学好
      

  4.   

    if (!string.IsNullOrEmpty(B1.Text) ||! string.IsNullOrEmpty(B2.Text ) )
      

  5.   

    if (this.textBox1.Text == "" || this.textBox2.Text == "")
                {
                    MessageBox.Show("班级编号和名称不能为空!");
                }
      

  6.   

    C# codeif (this.textBox1.Text == "" || this.textBox2.Text == "")
                {
                    MessageBox.Show("输入的不能为空,请重新输入!");
                }
      

  7.   

    该说的都说了 另外 你发现自己写的东西有问题 你可以写个实例测试下 调试你要学会 这样自己都能找到自己的代码的bug的