欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C#用記事本編寫簡(jiǎn)單WinForm窗體程序

 更新時(shí)間:2019年03月29日 08:37:05   作者:cvMat  
這篇文章主要為大家詳細(xì)介紹了C#用記事本編寫簡(jiǎn)單WinForm窗體程序,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

平時(shí)我們編寫WinForm程序經(jīng)常使用VS進(jìn)行拖控件的方式,這樣做雖然簡(jiǎn)單,但是無法深入了解WinForm程序的本質(zhì)。其實(shí),用記事本也可以編寫出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();

    //設(shè)置按鈕屬性
    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;

    //設(shè)置按鈕控件點(diǎn)擊事件
    this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
    //將構(gòu)造的控件添加到窗體Controls控件集合
    this.Controls.Add(btnClose);
  }
  //按鈕點(diǎn)擊事件
   private void btnClose_Click(object sender,EventArgs e)
   {
   this.Close();
   }
 }
 public class Program
 {
  //程序入口
  public static void Main()
  {
   Application.Run(new Form1());
  }
 }
}

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

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

3、目錄切換完畢后,輸入以下代碼運(yùn)行

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

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


以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論