问题
How do you get a class to interact with the form to show a message box?
回答1:
using System.Windows.Forms;
...
MessageBox.Show("Hello World!");
回答2:
System.Windows.MessageBox.Show("Hello world"); //WPF
System.Windows.Forms.MessageBox.Show("Hello world"); //WinForms
回答3:
Try this:
System.Windows.Forms.MessageBox.Show("Here's a message!");
回答4:
using System.Windows.Forms;
public class message
{
static void Main()
{
MessageBox.Show("Hello World!");
}
}
来源:https://stackoverflow.com/questions/715206/show-a-message-box-from-a-class-in-c