语言规范
:
一
.
数据类型
:
1.
值类型
:
1.1:
整数类型
:
类型
|
基类
|
位数
|
说明
|
Sbyte
|
System.Sbyte
|
1
|
-128-127
|
Byte
|
System.Byte
|
1
|
0-255
|
Shot
|
System.Int16
|
2
|
有符号短整型
|
Ushort
|
System.UInt16
|
2
|
无符号短整型
|
Int
|
System.Int32
|
4
|
|
Uint
|
System.UInt32
|
4
|
|
Long
|
System.Int64
|
8
|
|
Ulong
|
System.UInt64
|
8
|
|
1.2:
布尔型
:
bool
取值
true
与
false
1.3:
字符类型
:
char
表示
Unicode
字符
,2
个字节
System.Char
转义字符
:/',/",//,/0--
空字符
,/a--
感叹号
,/b--
退格
,/f--
换页
,/n--
新行
,/r
回车
,/t--
水平
Tab,/v--
垂直
Tab
1.4:实数:
double--- System.Double与 float--- System.Single
decimal为货币方面专门设计的 System.Decimal
1.5:结构类型:
public struct customer
{
public string cId;
public string name;
}
customer c1;
1.6:枚举类型:
Enum WeekDay{
Monday=1,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday
};
WeekDay day;
2.引用类型:
2.1:类类型:
class Customer
{
private string cId;
private string name;
public void show()
{
Console.WriteLine(“客户号:{0},客户名称为:{1}”,cId,name);
}
}
2.2:对象类型:
Customer c1 = new Customer();
C1.show();
2.3:字符串
string s = “hello world”;
2.4:接口
interface IdataSave
{
bool DataSaved();
}
2.5:数组:
string [] s={“a”,”b”}
Length返回一维数组的长度
GetLength返回指定维数的长度
Sort,Reverse排序
2.6:委托:
delegate void DgMethod(int a)
DgMethod与要委托的方法必须参数与返回类型都相同才行
方法:void show(int a)
1. DgMethod dm = new DgMethod(show);//委托给show方法
2. dm(10);//调用