[PROJECTNAME]
C# Coding convention
Date [May 18, 2010]
Version [1.1]
Status [Approved]
Author [Nguyen Thi Thanh Thuy, CEO]
Reviewed by [Le Tat Hai, Technical Director]
Approved by [Nguyen Thi Thanh Thuy, CEO]
Smart World Technology Co. ltd.
Address: 02 No Trang Long Street, ward 13, Binh Thanh District, HCMC Vietnam
Phone: 84-8-6674 9024 Fax: 84-8-6258 4459 Website: www.smartworld.com.vn
1
Revision History
Date Version Description Author
07/8/2011 1.0 State out basically coding standard for C Sharp
language
07/8/2011 1.0 Added naming of GUI controls in VS C# 2005
07/8/2011 1.0 Fixed Method style from camelCase to PascalCase
Smart World Technology Co. ltd.
Address: 02 No Trang Long Street, ward 13, Binh Thanh District, HCMC Vietnam
Phone: 84-8-6674 9024 Fax: 84-8-6258 4459 Website: www.smartworld.com.vn
2
Table of Contents
1. INTRODUCTION ..................................................................................................................... 4
2. CODING CONVENTIONS ....................................................................................................... 4
Smart World Technology Co. ltd.
Address: 02 No Trang Long Street, ward 13, Binh Thanh District, HCMC Vietnam
Phone: 84-8-6674 9024 Fax: 84-8-6258 4459 Website: www.smartworld.com.vn
3
1. Introduction
This document is specified for SWT’s developers who will attempt to a C# project development.
The developers should read this specification for standardization coding style and understandable
for other teammates. After all, it could make your project more standard and professional.
Note that, this document just specified with C# Language.
2. Coding Conventions
2.1. Terminology and Definition
Access Modifier C# keywords public, protected, internal, and private declare the allowed code-
accessibility of types and their members. Although default access modifiers vary, classes and
most other members use the default of private. Notable exceptions are interfaces and enumerate
which both default to public.
Camel Case: A word with the first letter lowercase, and the first letter of each subsequent word-
part capitalized. Example: customerNameAndThings
Pascal Case: A word with the first letter capitalized, and the first letter of each subsequent word-
part capitalized. Example: CustomerNameAndThings
Always : It must be follow this specification as a law.
Avoid: It should be avoid use this specification. In worst, it could be use.
Never: Every exceptions of this case is not allowed.
Possible: It recommend follow this specification.
2.2. Naming Conventions
“c” camelCase
“P” PascalCase
“U” UPPERCASE
“_” Prefix with “_”
2.3. Field
-Avoid using public field. (it’s not recommend of using public)
-Pascal Case if public or prefix with “_and Pascal Case if access modifier is protected,
internal, private. Examples:
public string Name;
private int _Age;
-Any GUI controls could be named with PascalCase but it’s must be prefix with GUI type
(or abbreviate type). Example:
Control Name Prefix Example
Label lb lbLable
Button bt btButton
ListBox ls lsListBox
Smart World Technology Co. ltd.
Address: 02 No Trang Long Street, ward 13, Binh Thanh District, HCMC Vietnam
Phone: 84-8-6674 9024 Fax: 84-8-6258 4459 Website: www.smartworld.com.vn
4
RadioButton (Option
buttons)
op opRadioButton
ComboBox cb cbComBox
MenuStrip mnu mnuMenuStrip
TextBox tx txTextBox
CheckBox ck ckCheckBox
CheckedListBox ckl cklCheckListBox
ListView lv lvListView
PictureBox pb pbPictureBox
TreeView trv trvTreeView
Panel pn pnPanel
GroupBox gb gbGroupBox
RichTextBox rtx rtxRichTextBox
Control Name Prefix Example
LinkLabel lkl lklLinkLabel
ProgressBar pgb pgbProgressBar
ToolTip tt ttToolTip
TabControl tbc tbcTapControl
ContextMenuStrip cmnu cmnuContextMenuStrip
StatusStrip sts stsStatusStrip
ImageList imgl imglImageList
Timer tm tmTimer
Smart World Technology Co. ltd.
Address: 02 No Trang Long Street, ward 13, Binh Thanh District, HCMC Vietnam
Phone: 84-8-6674 9024 Fax: 84-8-6258 4459 Website: www.smartworld.com.v
5