Show a message box from a class in c#?

2019-02-16 06:59发布

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

4条回答
小情绪 Triste *
2楼-- · 2019-02-16 07:25

Try this:

System.Windows.Forms.MessageBox.Show("Here's a message!");
查看更多
贼婆χ
3楼-- · 2019-02-16 07:41
using System.Windows.Forms;
...
MessageBox.Show("Hello World!");
查看更多
Anthone
4楼-- · 2019-02-16 07:43
System.Windows.MessageBox.Show("Hello world"); //WPF
System.Windows.Forms.MessageBox.Show("Hello world"); //WinForms
查看更多
够拽才男人
5楼-- · 2019-02-16 07:47
using System.Windows.Forms;

public class message
{
    static void Main()
    {  
        MessageBox.Show("Hello World!"); 
    }
}
查看更多
登录 后发表回答