Ash
Ash

Reputation: 9101

Show a message box from a class in c#?

How do you get a class to interact with the form to show a message box?

Upvotes: 30

Views: 135595

Answers (4)

John Gietzen
John Gietzen

Reputation: 49564

using System.Windows.Forms;
...
MessageBox.Show("Hello World!");

Upvotes: 41

Mehrdad Afshari
Mehrdad Afshari

Reputation: 422252

System.Windows.MessageBox.Show("Hello world"); //WPF
System.Windows.Forms.MessageBox.Show("Hello world"); //WinForms

Upvotes: 15

Keith Gaughan
Keith Gaughan

Reputation: 22705

Try this:

System.Windows.Forms.MessageBox.Show("Here's a message!");

Upvotes: 4

Konstantin Tarkus
Konstantin Tarkus

Reputation: 38428

using System.Windows.Forms;

public class message
{
    static void Main()
    {  
        MessageBox.Show("Hello World!"); 
    }
}

Upvotes: 3

Related Questions