MessageBox.Show(IWin32Window owner,string text) owner Type: System.Windows.Forms.IWin32Window An implementation of IWin32Window that will own the modal dialog box. text Type: System.String The text to display in the message box. from msdn
判断是否为空,提示 string strErr; if (string.IsNullOrEmpty(strErr)) { MessageBox.Show(this.strErr); return; } this于引用类的当前实例,也包括继承而来的方法
if (strErr != "")
{
MessageBox.Show(this,strErr); //this与strErr。
return;
}
声明变量 要赋值了 不然提示错误
owner
Type: System.Windows.Forms.IWin32Window
An implementation of IWin32Window that will own the modal dialog box. text
Type: System.String
The text to display in the message box. from msdn
string strErr;
if (string.IsNullOrEmpty(strErr))
{
MessageBox.Show(this.strErr);
return;
}
this于引用类的当前实例,也包括继承而来的方法
if (strErr != "")
{
MessageBox.Show(this,strErr); //this与strErr。
return;
}這個是原句。當他不等于的空的時候執行下麵的語句,這我知道,我只是想问的是:
this与strErr。为什么要这样写 this是引用当前实例,这我也知道作用是什么??、
这个代码的意思是:如果不等于空值,那么就执行下面的代码
所以在引用此方法的时候。 判断是否为空,为空提出提示框。恩,感谢5楼
{
MessageBox.Show(this,Str);
}
大概意思是不是想 当字符串不为空的时候,弹出对话框告诉Str哈,如果你的弹出对话框是已经封装好的方法的话,我觉得你的this这个参数应该是This.Page 呵呵呵 不一定正解。。