利用 C# 開發工具自動完成建立一些基本的代碼

來源:互聯網
上載者:User

 

       自學C#有時在IDE中存在的很多好的功能由於交流的人比較少,學習確實有些困難,但這些小技巧的確是減少代碼的編碼量,而其還非常的規範。

      我在網上希望找到一些這方面的資料,沒有發現。估計對於大多數人通過系統的學習和相互的交流較容易的掌握。

     可能我總結的僅僅是一小部分,希望瞭解更多的朋友給予補充。我在這裡先謝謝了。。。。。。。。

一,封裝屬性,欄位

1.聲明一個局部變數

       private int _ID;                    //'*編號

2.滑鼠選中這個變數名,按右鍵-重構-封裝欄位

        public int ID
        {
            get { return _ID; }
            set { _ID = value; }
        }

二,實現介面

1.滑鼠選中這個類要實現的介面名稱,按右鍵-實現介面-實現顯示介面

class DBCustomer:DBbase,DBbase .ITableOperate
    {

        #region ITableOperate 成員

        void DBbase.ITableOperate.AddNew()
        {
            throw new Exception("The method or operation is not implemented.");
        }

        void DBbase.ITableOperate.Update(long ID)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        #endregion

     }

三,注釋

1.欄位

在聲明的欄位的上一行寫“///”斷行符號後,自動產生下面的代碼

       private int _ID;                   

        /// <summary>
        ///

        /// </summary>
        public int ID
        {
            get { return _ID; }
            set { _ID = value; }
        }

在中間插入這個欄位的注釋文字

       private int _ID;                   

        /// <summary>
        /// 編號
        /// </summary>
        public int ID
        {
            get { return _ID; }
            set { _ID = value; }
        }

2.方法

在聲明的方法的上一行寫“///”斷行符號後,自動產生下面的代碼

        /// <summary>
        ///
        /// </summary>
        /// <param name="strSQL"></param>
        /// <param name="LV"></param>
        /// <param name="ImageID"></param>
            public void QueryToLV(String strSQL , ref ListView LV , int ImageID )

在寫入注釋內容 其實可能包括(參數,傳回值 由方法體內動自動產生)

        /// <summary>
        /// 查詢結果匯入到ListView
        /// </summary>
        /// <param name="strSQL">查詢語句</param>
        /// <param name="LV">ListView控制項</param>
        /// <param name="ImageID">ListView Item使用的小表徵圖ID</param>
            public void QueryToLV(String strSQL , ref ListView LV , int ImageID )

                                                                                       作者:段利慶

                                                                                         2010-03-25

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.