https://learn.microsoft.com/zh-cn/dotnet/api/system.windows.forms.form?view=windowsdesktop-10.0
hello.cs
cs
using System.Windows.Forms;
using System.Drawing;
class Program {
static void Main() {
Form form1 = new Form();
Button button1 = new Button ();
Button button2 = new Button ();
button1.Text = "OK";
button1.Location = new Point (10, 10);
button2.Text = "Cancel";
button2.Location = new Point (button1.Left, button1.Height + button1.Top + 10);
form1.Text = "My Dialog Box";
form1.HelpButton = true;
form1.FormBorderStyle = FormBorderStyle.FixedDialog;
form1.MaximizeBox = false;
form1.MinimizeBox = false;
form1.AcceptButton = button1;
form1.CancelButton = button2;
form1.StartPosition = FormStartPosition.CenterScreen;
form1.Controls.Add(button1);
form1.Controls.Add(button2);
form1.ShowDialog();
}
}
编译
C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc /target:exe /out:hello.exe hello.cs
运行
hello
