c#命名規範,控制項命名規則

來源:互聯網
上載者:User
NET命名規範

1、 
命名空間

使用Pascal大小寫,和類不要使用同樣的名稱,規則公司名+技術名稱+功能

樣本:AQH.BLL

2、 
使用Pascal大小寫,用名字或名字短語命名

樣本:public class Button

3、 
使用Pascal大小寫,給介面名字加上字母I首碼

樣本:public interface IServiceProvider

4、 
屬性Attribute

應該總是將尾碼Attribute 添加到自訂屬性類中

樣本:public class ObsoleteAttribute

5、 
枚舉Enum

Enum類型與值使用Pascal大小寫

6、 
參數

使用Camel大小寫

樣本:GetType(string typeName)

      Format(string format)

7、 
方法

使用動詞命名方法,使用Pascal大小寫

樣本:RemoveAll() GetNextStudent()

8、 
屬性 Property

使用名字命名屬性,使用Pascal大小寫

9、 
事件

使用EventHandler尾碼,使用Pacal大小寫

樣本:public delegate void MouseEventHandler(object sender,MouseEventArgs
e)

10、             
常量 Const

所有動詞大寫,多個單詞用底線隔開

樣本:public const string PACE_TITLE=”Welcome”;

11、             
欄位

Private 、protected 使用Camel大小寫

Public使用Pacal大小寫

控制項簡寫對照表

Button

btn

btnSubmit

CheckBox

chk

chkBlue

CheckBoxList

chkl

chklBlue

DropDownList

drop

dropCatagory

HyperLink

lnk

lnkDetail

Image

img

imgPhone

Label

lbl

lblResults

Panel

pnl

pnlForm1

RadioButton

rad

radBlue

Repeater

rpt

rptQueryResult

Table

tbl

tblCategory

TextBox

txt

txtFirstName

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.