【发布时间】:2009-04-03 18:59:40
【问题描述】:
如何让类与表单交互以显示消息框?
【问题讨论】:
-
这通常不是一个好主意。理想情况下,该类应该将数据发送回表单并让表单显示消息框。如果您将 UI 细节编码到您的类中,那么它完全与该 UI 相关联。此外,它使单元测试变得不可能。
标签: c# class messagebox
如何让类与表单交互以显示消息框?
【问题讨论】:
标签: c# class messagebox
using System.Windows.Forms;
...
MessageBox.Show("Hello World!");
【讨论】:
System.Windows.MessageBox.Show("Hello world"); //WPF
System.Windows.Forms.MessageBox.Show("Hello world"); //WinForms
【讨论】:
试试这个:
System.Windows.Forms.MessageBox.Show("Here's a message!");
【讨论】:
using System.Windows.Forms;
public class message
{
static void Main()
{
MessageBox.Show("Hello World!");
}
}
【讨论】: