【发布时间】:2012-07-23 15:19:41
【问题描述】:
在 Visual Studio C# Express 上,当我运行下面的脚本时,我在行中收到以下错误消息:
如果(ofd.ShowDialog() == true): 错误 1 运算符“==”不能应用于“System.Windows.Forms.DialogResult”和“bool”类型的操作数
我该如何解决这个问题?代码如下:
public override GH_ObjectResponse RespondToMouseDoubleClick(GH_Canvas sender, GH_CanvasMouseEvent e)
{
System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
ofd.Multiselect = true;
ofd.Filter = "Data Sources (*.ini)|*.ini*|All Files|*.*";
if (ofd.ShowDialog() == true)
{
string[] filePath = ofd.FileNames;
string[] safeFilePath = ofd.SafeFileNames;
}
return base.RespondToMouseDoubleClick(sender, e);
}
【问题讨论】:
-
if (ofdShowDialog() == DialogResult.OK)
标签: c# visual-studio-2010 forms