C#的控制台程序中如何弹出消息框???

382度:你好!
我的在System命名空间之下就没有Windows。这是为什么?

这种问题没有“应该这样”或者“应该那样”,哪怕最简单的东西,都可以亲身去试一下得到正确的结果:

首先,在解决方案的“引用”中点右键选择“添加引用”,再选择“.NET”组件的System.Windows.Fomrs,加入对于窗体框架的支持,就可以在代码中添加using System.Windows.Forms;
你的System命名空间下没有Windows,是因为控制台程序默认不支持Windows窗体,需要你自己添加的。

接着就很简单了,在Main方法中输入MessageBox.Show("something");试试

using System;
using System.IO;
using System.Windows.Forms;

class Program
{
static void Main()
{
MessageBox.Show("Hello world!");
}
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-04-05
先在项目中添加System.Windows.Forms引用,然后在程序中调用System.Windows.Forms.MessageBox.Show("hello!")
第2个回答  2010-04-05
不行的.
只能用 console打印
第3个回答  2010-04-05
应该说不行吧。
相似回答