004_Types

Value Types - 值类型

值类型派生自System.ValueType。值类型的变量直接包含它们的值。

值类型的两大类别分别是:struct 和 enum。内建数字类型是:struct型。

值类型是封闭的,意味着此类不能被继承。不能定义派生自用户自定义类和struct的struct,因为struct只能派生自System.ValueType。

enum派生自System.Enum,System.Enum派生自System.ValueType。

Reference Types - 引用类型

刚声明的引用类型的值为:null 直到被分配对象。声明接口类型的变量,同时必须初始化为实现该接口的类。

数组是引用类型

Generic Types - 泛型

List<string> stringList = new List<string>();
stringList.Add("String example");
// compile time error adding a type other than a string:
stringList.Add(4);

Nullable Types

通常值类型不能分配null值,类型名称后,后缀? 此种情况可以分配null值,例如:int?

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值