How do you get a class to interact with the form to show a message box?
Asked
Active
Viewed 1.3e+01k times
30
-
6This isn't normally a good idea. Ideally, the class should send the data back to the form and let the form show the message box. If you code UI specifics into your class then it is completely tied to that UI. Also, it makes unit testing impossible. – NotMe Apr 03 '09 at 19:08
4 Answers
15
System.Windows.MessageBox.Show("Hello world"); //WPF
System.Windows.Forms.MessageBox.Show("Hello world"); //WinForms

Mehrdad Afshari
- 414,610
- 91
- 852
- 789
3
using System.Windows.Forms;
public class message
{
static void Main()
{
MessageBox.Show("Hello World!");
}
}

Konstantin Tarkus
- 37,618
- 14
- 135
- 121