且构网

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

System.Windows.MessageBox VS System.Windows.Forms.MessageBox

更新时间:2023-12-06 14:18:04

System.Windows.MessageBox 加入与WPF和WPF组件中存在(presentationFramework.dll)。

System.Windows.MessageBox was added with WPF, and exists within the WPF assemblies (PresentationFramework.dll).

System.Windows.Forms.MessageBox 添加Windows窗体,并在Windows窗体组件存在。

System.Windows.Forms.MessageBox was added with Windows Forms, and exists within the Windows Forms assemblies.

如果你的程序是一个Windows窗体程序,我会用后者( System.Windows.Forms.MessageBox ),因为它不会在依赖拉WPF。在另一方面,如果你正在为WPF,我会使用 System.Windows.MessageBox

If your program is a Windows Forms program, I would use the latter (System.Windows.Forms.MessageBox), as it won't pull in a dependency on WPF. On the other hand, if you are developing for WPF, I'd use System.Windows.MessageBox.