using System; using System.Windows.Forms; namespace WindowsFormsApp { public class MainForm : Form { public MainForm() { Button btn = new Button(); btn.Text = "Click Me"; btn.Location = new System.Drawing.Point(50, 50); btn.Click += (sender, e) => MessageBox.Show("Button Clicked!"); this.Controls.Add(btn); this.Text = "My First Form"; } [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); } } }