面向对象的C#语言 课件 .pdf
第2章面向对象的C#语言
C#语言基础
2.1C#语言的数据类型
2.2字符串类型
2.3数据类型转换
2.4值类型变量转换为对象
2.5类
2.6类的层次关系
2.7接口
2.8委托
2.9事件
2.10数组
2.11集合类
2.12命名空间
2.13异常
2.14Lambda运算符与表达式
2.15var、dynamic
2.16匿名类型
•内置类型表
2.1数据类型
C#内置类型表
内置C#类型.NETFramework类型
boolSystem.Boolean
byteSystem.Byte
sbyteSystem.SByte
charSystem.Char
decimalSystem.Decimal
doubleSystem.Double
floatSystem.Single
intSystem.Int32
uintSystem.UInt32
longSystem.Int64
ulongSystem.UInt64
objectSystem.Object
shortSystem.Int16
ushortSystem.UInt16
stringSystem.String
以布尔类型为例
boolb1=newBoolean();
也可以写作:
boolb1=newbool();
较为直观、方便的写法是:
boolb3=false;
无论是使用bool还是Boolean,都不能改变这个
数据类型是值类型的本质。
usingSystem;
namespaceEx1._1_DataType
{
classProgram
{
staticvoidMain(string[]args)
{
boolb1=newBoolean();
boolb2=b1;
Booleanb3=true;
b1=true;
Console.WriteLine({0},{1},{2},{3},b1,b2,b3,b1==
b2);
}运行结果为:
}