我有一個像這樣的函數,它檢查字段是空的還是空的,然後將setError圖標放在文本框的旁邊。string.empty和string.isnullorempty
private bool ValidateHost()
{
ErrorProvider errorProvider = new ErrorProvider();
bool isValid = true;
//If the txtHost is empty, show a message to user
if(txtHost.Text == string.Empty)
{
errorProvider.SetError(txtHost, "Please enter the host address");
isValid = false;
}
else
errorProvider.SetError(txtHost, string.Empty);
return isValid;
}
,但是當我試圖用字符串,然後isnullorempty我沒有得到SETERROR圖標.. 你們可以PLZ告訴我什麼是在這種情況下使用string.isnullorempty的正確方法..
*你*是如何使用它的?它應該能夠很好地處理`if(string.IsNullOrEmpty(txtHost.Text))`。 – 2010-11-30 10:59:35
「恐怖圖標」? – annakata 2010-11-30 11:01:22