You are on page 1of 10

April 12, 2010

MN XY DNG PHN MM

C# CODING STANDARD - NHM 26, 27, 28, 29, 30

Page 1

April 12, 2010

MN XY DNG PHN MM

MC LC
I. II. Ngn ng s dng: Gii thch code (comment): 1. Dng 1: Gii thch ngha phng thc hm 2. Dng 2: Dng Gii thch ngha tn bin 3. Dng 3: Gii thiu s lc v Class III. Cch t tn bin trong Class Phng Thc Chun Control: 1. Bin: 2. Class: 3. Phng thc: 4. Chun cc Control: IV. Ton t s hc v du ngoc: 1. Ton t s hc v ton t tng/gim: 2. Lnh r nhnh: 3. Lnh lp: V. Ti liu tham kho: 3 3 3 3 3 6 4 4 4 5 6 6 7 8 10

C# CODING STANDARD - NHM 26, 27, 28, 29, 30

Page 2

April 12, 2010

MN XY DNG PHN MM

I.

Ngn ng s dng: Ting Vit (100%).

II.

Gii thch code (comment):


1. Dng 1: gii thch ngha phng thc - hm Thay /**/ Thnh: /** * dng 1 * dng 2 */ 2. Dng 2: dng gii thch ngha tn bin Thay //y l phng thc A Thnh: // y l phng thc A 3. Dng 3: gii thiu s lc v Class /// <summary> /// Lp ny cung cp 2 phng thc tnh tng v tch hai phn s /// Bao gm cc phng thc sau: /// /// 1) void TinhTongHaiPhanSo() /// 2) void TinhTichHaiPhanSo() /// /// </summary>

III.

Cch t tn Bin Phng thc Class/Struct:

1. Bin:
Trong vng lp (for/ while/ dowhile): ch s dng cc bin i, j, k.

C# CODING STANDARD - NHM 26, 27, 28, 29, 30

Page 3

April 12, 2010 VD: -

MN XY DNG PHN MM for (int j = 0, j = 0, k = 0; ...)

Trong class: VD: private int m_intTu; Trong cc phng thc: VD: PhanSo psKetQua; // Phn ghi ch - comments

2. Class:
Tn Class: theo quy c / chun Pascal.

Public class PhanSo { private int m_intTu; public int Tu { get { return m_intTu; } set { m_intTu = value; } } }

3. Phng Thc:
Tn phng thc: theo quy c / chun Pascal. VD: public PhanSo TongHaiPhanSo()

Bin trong phng thc: public PhanSo TongHaiPhanSo(PhanSo psA, PhanSo psB) { PhanSo psKetQua; // Ghi ch

C# CODING STANDARD - NHM 26, 27, 28, 29, 30

Page 4

April 12, 2010

MN XY DNG PHN MM // Cch t tn bin trong Phng Thc: bool blnTenBien; char chrTenBien; string strTenBien; short shtTenBien; ushort ushtTenBien; int intTenBien; uint uintTenBien; long lngTenBien; ulong ulngTenBien; float fltTenBien; double dblTenBien; Object objTenBien; DateTime dtmTenBien; ArrayList arrlstTenMang = new ArrayList(); return psKetQua;

4. Chun Control:
lbl llbl but txt mnu chk rdo grp pic Label LinkLabel Button Textbox MainMenu CheckBox RadioButton GroupBox PictureBox grd lst cbo lstv tre tab dtm mon sbr Grid ListBox ComboBox ListView TreeView TabControl DateTimePicker MonthCalendar ScrollBar

C# CODING STANDARD - NHM 26, 27, 28, 29, 30

Page 5

April 12, 2010

MN XY DNG PHN MM

tmr spl dud nud trk pro rtxt img hlp tip cmnu tbr frm bar nico ofd sfd fd cd pd ppd ppc

Timer Splitter DomainUpDown NumericUpDown TrackBar ProgressBar RichTextBox ImageList HelpProvider ToolTip ContextMenu ToolBar Form StatusBar NotifyIcon OpenFileDialog SaveFileDialog FontDialog ColorDialog PrintDialog PrintPreviewDialog PrintPreviewControl

err pdoc psd crv pd fsw log dire dirs msq pco pro ser rpt ds olea olec oled sqla sqlc sqld dvw

ErrorProvider PrintDocument PageSetupDialog CrystalReportViewer PrintDialog FileSystemWatcher EventLog DirectoryEntry DirectorySearcher MessageQueue PerformanceCounter Process ServiceController ReportDocument DataSet OleDbDataAdapter OleDbConnection OleDbCommand SqlDbDataAdapter SqlDbConnection SqlDbCommand DataView

IV.

Ton t tng/gim v du ngoc:

1. Ton t s hc v tng/gim:

C# CODING STANDARD - NHM 26, 27, 28, 29, 30

Page 6

April 12, 2010

MN XY DNG PHN MM

2. Cu lnh r nhnh: a. if if ... else if else if:

i vi cc cu lnh if: ch c lng ti a 3 ln.

C# CODING STANDARD - NHM 26, 27, 28, 29, 30

Page 7

April 12, 2010

MN XY DNG PHN MM

b. switch case:

3. Cu lnh lp: a. for:

b. while:

C# CODING STANDARD - NHM 26, 27, 28, 29, 30

Page 8

April 12, 2010

MN XY DNG PHN MM

c. dowhile:

d. Lu :

C# CODING STANDARD - NHM 26, 27, 28, 29, 30

Page 9

April 12, 2010

MN XY DNG PHN MM

V.

Ti liu tham kho:


1. Chun code C Sharp Coding Convention ca FPT Software. 2. Philips Healthcare - C# Coding Standard. 3. Scott Bellware - C# Code Style Guide.

C# CODING STANDARD - NHM 26, 27, 28, 29, 30

Page 10

You might also like