Show a message box from a class in c#?

不打扰是莪最后的温柔 提交于 2019-12-19 05:03:23

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!