我写了一些代码如下:
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对这个文件进行编译后产生一个可执行文件,执行它,可以看到如下界面:

这是我没有设置好呢,还是mono对中文的支持不好?