且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法将类型'System.Windows.Forms.ProgressBar'隐式转换为'System.Windows.Forms.Button'和& System.Windows.Forms.FolderBrowserDialog”

更新时间:2023-12-06 14:17:58

你不能隐式地转换它们,但不能以任何其他方式转换它们。我不知道是什么让你试图进行这样的转换。你的代码示例没有显示任何相关的内容。



看,当你尝试编译任何东西时,编译器会给你确切的问题所在的行。而且你甚至没有显示这些行,表明每个案例的错误信息(更好的是以评论的形式)。当然,你需要展示足够的背景。



-SA


Am working on an application using C# and am in a line that

if (this._Button5 != null)
this._Button5.Click -= new EventHandler(this.Button5_Click);
this._Button5 = WithEventsValue;

Am having 5 Buttons & 1 FolderbrowserDialog which I want to assign to WithEventsValue.

Am getting error as "

Cannot implicitly convert type 'System.Windows.Forms.ProgressBar' to 'System.Windows.Forms.Button'

Cannot implicitly convert type 'System.Windows.Forms.ProgressBar' to 'System.Windows.Forms.FolderBrowserDialog'


Thanks in Advance

You cannot convert them not only implicitly, but in any other way. I have no idea what makes you trying to do such conversion. Your code sample does not show anything relevant.

Look, when you try to compile anything, the compiler gives you exact line(s) where the problem is. And you don't even show these lines indicating error information on each case (better be in the form of comment). And of course you need to show sufficient context.

—SA