11. Types

博客介绍了C#语言的类型,主要分为值类型和引用类型,还有仅在不安全代码中可用的指针类型。值类型变量直接包含数据,引用类型变量存储数据引用。C#类型系统统一,任何类型值都可视为对象,值类型通过装箱和拆箱操作处理。
11. Types
The types of the C# language are divided into two main categories: Value
types and reference types.
type:
value-type
reference-type
A third category of types, pointers, is available only in unsafe code. This
is discussed further in §25.2.
Value types differ from reference types in that variables of the value
types directly contain their data,
whereas variables of the reference types store references to their data,
the latter being known as objects.
With reference types, it is possible for two variables to reference the
same object, and thus possible for
operations on one variable to affect the object referenced by the other
variable. With value types, the
variables each have their own copy of the data, and it is not possible for
operations on one to affect the other.
C#.s type system is unified such that a value of any type can be treated as
an object. Every type in C#
directly or indirectly derives from the object class type, and object is
the ultimate base class of all types.
Values of reference types are treated as objects simply by viewing the
values as type object. Values of
value types are treated as objects by performing boxing and unboxing
operations (§11.3).
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值