All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
C#教程:C#数据类型之装箱和拆箱

Writer: qq Article type: Programming skills(编程技巧) Time: 2014/7/11 9:21:54 Browse times: 318 Comment times: 0

C#教程:C#数据类型之装箱和拆箱


Head photo

Go homepage
Upload pictures
Write articles

C#教程:C#数据类型之装箱和拆箱

C#数据类型之装箱和拆箱
装箱就是将值类型转换为引用类型Object,这使得值类型可以存储在垃圾回收堆中。
拆箱将从对象中提取值类型。拆箱就是将引用类型转换为值类型。例如:
int i = 929;
object o = (object) i; // 装箱
o = 123;
i = (int) o; // 拆箱
本教程来自http://www.isstudy.com
相对于简单的赋值而言,装箱和拆箱过程需要进行大量的计算。对值类型进行装箱时,必须分配并构造一个全新的对象。拆箱所需的强制转换也需要进行大量的计算。因此装箱、拆箱会对性能产生影响。





There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.