你好!用你上面说的.IsNullOrWhiteSpace 不行private bool CheckRSVNameBox(ref TextBox textbox)
{if (string.IsNullOrEmpty(txtBox.Text.Trim ()) {
textbox.BackColor = Color.Red;
return false;
}
}
if (!CheckRSVNameBox( ref txtboxRSVName)) {
ErrCount++;
}
文本框name为txtboxRSVName,谢谢
string.IsNullOrWhiteSpace不行,是因为你的vs不是2010,只有.net framework 4.0以上才支持这个方法。
可以使用string.IsNullOrEmpty(Text.Trim())代替。
错误1“XS_DSChecker.PersonInfosDetailForm.CheckNameBox(refSystem.Windows.Forms.TextBox)”: 并非所有的代码路径都返回值
我现在用的是 string.IsNullOrEmpty(txtBox.Text.Trim ()); 代替了; 但是方法提示上的错误信息
private bool CheckRSVNameBox(ref TextBox textbox)
{
if (string.IsNullOrEmpty(textbox.Text.Trim ()) {
textbox.BackColor = Color.Red;
return false;
}
return true;
}
if (!CheckRSVNameBox( ref txtboxRSVName)) {
ErrCount++;
}
提问者很懒!!!
我按照 你上面说的做了,还是不行 ,错误信息错误: 并非所有的代码路径都返回值
private bool CheckRSVNameBox(ref TextBox textbox)
{if (textbox.Text.Trim()=="")
{
textbox.BackColor = Color.Red;
return false;
}
}
if (!CheckRSVNameBox( ref txtboxRSVName)) {
ErrCount++;
}
我这样处理但是不行! 请问一下应该如果应用? 谢谢