進制 2 10 8 16
00000111 = 7? 1*2^0 + 1*2^1 +1*2^2 + 0*2^3……+0*2^7? 2轉(zhuǎn)10
71 = 57? ? 1*8^0 + 7*8^1? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 8轉(zhuǎn)10
0x? 0 1 2 3 4 5 6 7 8 9 a b c d e f? ? ? ? ? ? ? ? ? 16轉(zhuǎn)10
0x20 = 32? 0*16^0 + 2* 16^1
00000000 ? ? ? ? ? ? ? ? ? ?1? 2? 4? 8? 16? 32? 64? 128? 256? 512? 1024? 2048
00111001? ? 57? ? ? ?? ? 57轉(zhuǎn)二進制
57 ==> 071 ? ? ? ? ? ? ? ? ?57轉(zhuǎn)八進制
57 ==> 0x39 ? ? ? ? ? ? ? ? 57轉(zhuǎn)十六進制
數(shù)據(jù)類型
int(整型) ? float(浮點) double(雙精度) ?Char(字符) ? bool (true ?or ?false) ? string(字符串) ? ? ? ? ? ?//值類型數(shù)據(jù)
?int a = 1;
?float b = 2.0f;
?char c = 'a'; ? ?//單個字符
變量和常量
命名
1.不能以數(shù)字開頭,但數(shù)字可放在其他地方
2.不能包含空白符(回車、空格…)
3.不能使用數(shù)學符號、連線、箭頭(——>)
4.不能使用合法或非法的ASCII碼
5.@只能作為開始,并且不能與關鍵字重名
int a = 1;
float b = 1.0f;
double c = 1.0;
char d = 'n';
bool e = true; ? //false
string f = "hellow";
見名知意、駝峰原則
變量(或常量)類型? 變量名 = 初始值;
int numberOfCar = 3;
int hp = 100;
numberOfCar = 4;
//變量與常量
交換 a. ?b值
int a = 2,b = 3;
int temp = a;
a = b;
b = temp;
Console.WriteLine ("a={0},b={1}",a,b);
a = a + b; ? ? ? ? ? ? //a=2+3=5
b = a - b; ? ? ? ? ? ? //b=5-3=2
a = a - b; ? ? ? ? ? ? //a=5-2=3
Console.WriteLine ("a={0},b={1}",a,b);
常量的關鍵字 Const
const int score = 90; ? ? ? //score 不能被再次賦值
score = 100;(X)
const float b;
float c = 2.0f;
默認值
Console.WriteLine("{0} is {1}",c,score);
0和1表示后續(xù)兩個數(shù)值的順序
Console.Write("{0}",sizeof(int));
分割線
#region?
? ? ? ? ? ?float b = 100.0f;
#endregion
#warning ? //警告
面向?qū)ο髢?nèi)容 ?17_8_21到8_24 ? ? ? ?22為參數(shù) ? ?OOP(面向?qū)ο缶幊? ? c#不支持多繼承 ?第九講