你用记事本写。然后用命令行编译。csc /t:winexe CSFileName
using System;
using System.Windows.Forms;
using System.Drawing;
namespace CreateUIByWriteCode
{
public class MainForm : Form
{
private Button TestBtn;
public MainForm()
{
this.TestBtn = new Button();
//
// TestBtn
//
this.TestBtn.Name = "TestBtn";
this.TestBtn.Text = "测试按钮";
this.TestBtn.Size = new Size(80, 45);
this.TestBtn.Location = new Point(100, 150);
//
// MainForm
//
this.Name = "MainForm";
this.Text = "测试窗口";
this.Controls.Add(this.TestBtn);
}
static void Main()
{
Application.Run(new MainForm());
}
}
}