我写了一些代码如下:
using system;
using system.drawing;
using system.collections;
using system.componentmodel;
using system.windows.forms;
using system.data;
namespace sample
{
public class formx : system.windows.forms.form
{
private system.componentmodel.container components = null;
private system.windows.forms.button btn = null;
public formx()
{
initializecomponent();
}
protected override void dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.dispose();
}
}
base.dispose( disposing );
}
private void initializecomponent()
{
this.components = new system.componentmodel.container();
this.size = new system.drawing.size(300,300);
this.text = "路亦平";
this.btn = new system.windows.forms.button();
this.btn.location = new system.drawing.point(100, 100);
this.btn.name = "btn";
this.btn.size = new system.drawing.size(56, 24);
this.btn.tabindex = 6;
this.btn.text = "确定";
this.controls.add(this.btn);
this.btn.click += new system.eventhandler(this.btn_click);
}
private void btn_click(object sender, system.eventargs e)
{
messagebox.show("中文");
this.close();
}
[stathread]
static void main()
{
application.run(new formx());
}
}
}
用mcs -r:system.windows.forms -r:system.drawing -r:system.data hello.cs对这个文件进行编译后产生一个可执行文件,执行它,可以看到如下界面:
