this.TextBox1.Text空字符问题

来源:百度知道 编辑:UC知道 时间:2024/06/22 03:37:03
string str= Convert.ToString(this.TextBox1.Text.Trim());
if (str == null)
{
this.TextBox1.Text = "safds";
}
TextBox1.Text的值为空,但是取出的结果为"",用str == null判断不是空,有什么办法可以判断TextBox1.Text的字段为空,谢谢!

if(String.IsNullOrEmpty(str)){
this.TextBox1.Text = "safds";
}

string str=this.TextBox1.Text.Trim();//只到这就行了,不用Convert....
if(str=="")
{

}

本来就是字符串你还tostring 干什么。。

if(string.IsNullOrEmpty(TextBox1.Text))

TextBox1.Text.Length == 0

if(str=="")