Professional Documents
Culture Documents
Ngn ng C# - Phn 1
.Net Framework
4 ngn ng : C#, VB.NET, C++.NET, Jscript.NET CLR - Common Language Runtime FCL Framework Class Library MSIL Microsoft Intermediate Language
.NET Framework
Mi tr ng pht trin
Microsoft Visual Studio .NET 2003 / 2005 / 2008 Console Dll Windows form Web
Vng tn - Namespaces
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using MyLibrary;
Vng tn - Namespaces
Namespace System cha cha nhiu lp giao tip vi h thng v cc lp cng dng chung
Vng tn - Namespaces
Ton t chm .
Ch nh tn lp trong namespace
T kha using
Kiu d liu
Kiu d liu
Ph ng thc ToString()
Kiu d liu
Mt s k t escape thng d ng
Character Single quote Double quote Backslash Null Alert Backspace Form feed New line Carriage return Tab character Vertical tab
S thnh chui
int so = 10;
Chui thnh s
string chuoi = so.ToString(); string chuoi = 12345; double n = double.Parse(chuoi); double n = Convert.ToDouble(chuoi); int n = Convert.ToInt32(chuoi);
int i;
Khai bo bin:
Cu lnh lp
While
while (l<r) { cu lnh } do { cu lnh } while (l<r)
Do..While
For
for (int i=0; i<n; i++) { cu lnh }
Cu lnh lp
Foreach
double[] arr = {1.0, 2.1, 3.5, 4.2, 5.3}; foreach (double temp in arr) { sum += temp; } for (int i=0; i<arr.Length; i++) { double temp = arr[i]; sum += temp; }
Cu lnh iu kin
If..else
if ( a => b ) { max = a; } else { max = b; }
Switch
switch (x) { case 1 : ; break; case 2 : ; break; default : ; break; }
Cc ton t
Category Arithmetic Logical String concatenation Increment and decrement Assignment Shortcut operator Shortcut operator Operator +-*/% & | ^ ~ && || ! + ++ -= += -= *= /= %= &= |= ^= <<= >>= ++ , -++ , --
Vit ghi ch
Cc php ton
Mt s hm thng dng
Ly gi tr tuyt i
Ly tha
Int x = Math.Abs(-16); Int x = Math.Pow(2,3); // x = 2^3 Double x = Math.Sqrt(4); // x = 2; Double x = Math.Round(0.1234,2) // x= 0.12
Ly cn
Lm trn
Mi trng VS2005
Ci t Visual Studio
B c 1 Ci t mi tr ng .NET 2005 B c 2 Ci t th vi n MSDN
Lm vic vi Solution
Solution
Project 1 Project 2 Project 2
HelloWorld
MyLibrary HelloWorld
MyLibrary: ng dng dll HelloWorld: ng dng Console
To mi mt project
M VS2005
To mi mt project
To mi mt project
To mi mt project
To mi mt project
To mi mt project
private void btnCong_Click(object sender, EventArgs e) { // Bc 1 : c d liu t control int so1 = Convert.ToInt32(txtSo1.Text); int so2 = Convert.ToInt32(txtSo2.Text); // Bc 2 : x l int tong = so1 + so2; // Bc 3 : xut kt qu ra control txtTong.Text = tong.ToString(); }
To mi mt project
Ch y ch ng trnh
Th o lu n
02/15/11
28/10