国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

C#用記事本編寫簡單WinForm窗體程序

2020-01-24 00:06:37
字體:
來源:轉載
供稿:網友

平時我們編寫WinForm程序經常使用VS進行拖控件的方式,這樣做雖然簡單,但是無法深入了解WinForm程序的本質。其實,用記事本也可以編寫出VS編寫的WinForm程序。還是直接看代碼吧:

1、打開記事本,寫入以下代碼,另存為hello.cs文件

using System;using System.Windows.Forms;namespace Hello{ public class Form1:Form {  private System.Windows.Forms.Button btnClose;  public Form1()  {    this.Text = "Form1窗體";    btnClose = new System.Windows.Forms.Button();    //將窗體掛起    this.SuspendLayout();    //設置按鈕屬性    this.btnClose.Location = new System.Drawing.Point(20,20);    this.btnClose.Size = new System.Drawing.Size(100,25);    this.btnClose.Name = "btnClose";    this.btnClose.Text = "按鈕";    this.btnClose.UseVisualStyleBackColor = true;    //設置按鈕控件點擊事件    this.btnClose.Click += new System.EventHandler(this.btnClose_Click);    //將構造的控件添加到窗體Controls控件集合    this.Controls.Add(btnClose);  }  //按鈕點擊事件   private void btnClose_Click(object sender,EventArgs e)   {   this.Close();   } } public class Program {  //程序入口  public static void Main()  {   Application.Run(new Form1());  } }}

2、在Windows搜索框輸入 cmd,打開控制臺,輸入以下代碼切換目錄

cd C:/Windows/Microsoft.NET/Framework/v4.0.30319

3、目錄切換完畢后,輸入以下代碼運行

csc.exe /out:e:/hello.exe e:/hello.cs

/out:e:/hello.exe用于指定可執行文件存放的目錄和名稱
e:/hello.cs用于指定源文件的文件路徑


以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 平潭县| 韶关市| 普宁市| 房山区| 仪征市| 武胜县| 香格里拉县| 喀喇沁旗| 宁城县| 博爱县| 江陵县| 许昌市| 永济市| 侯马市| 武强县| 化德县| 江北区| 罗城| 日照市| 舒兰市| 锦屏县| 阿巴嘎旗| 五峰| 舒兰市| SHOW| 桐梓县| 和政县| 涡阳县| 洞头县| 牡丹江市| 茌平县| 阳城县| 剑川县| 上饶县| 漳浦县| 西宁市| 皮山县| 双鸭山市| 双鸭山市| 东辽县| 论坛|