本文介绍了什么是("")之间的差异,(空)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试设置验证我起初遇到了一些问题,检查是否一个文本框为空,我用
While trying to set Validations i initially encountered some problems with checking if a textbox is null, i tried using
private void btnGo_Click(object sender, EventArgs e)
{
string name = textLogin.Text;
if (name == null)
{
labelError.Visiblle = true;
labelError.Text = "Field Cannot be Left Blank"
}
}
但它没有工作,直到我试过这种
but it didn't work, until i tried this
private void btnGo_Click(object sender, EventArgs e)
{
string name = textLogin.Text;
if (name == "")
{
labelError.Visiblle = true;
labelError.Text = "Field Cannot be Left Blank"
}
}
我的问题是我想知道(空)之间的差值(),为什么空是不工作。
My question is i want to know the difference between ("") and (null) and why null wasn't working.
在此先感谢
推荐答案
同为 0 和空数组的区别;一切。他们是不同的值。
,
是一个空字符串,这是一个空白文本框会怎样为文本就是一切。 空
没有价值,是不是一个空白文本框都有为文本
。
The same as the difference between
0
and an empty array; everything. They’re different values. ""
is an empty string, and that’s what a blank textbox holds as text is all. null
is no value, and is not what a blank textbox has as Text
.
这篇关于什么是("")之间的差异,(空)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!