当前位置:网站首页>Part C - value types and reference types
Part C - value types and reference types
2022-06-23 12:40:00 【First wife ash yuanai】
1. Value type and Reference type ( contrast )
Value type : | byte,short,int,long,float,double,decimal,char,bool and struct Collectively referred to as value types . |
Reference type : | string and class Collectively referred to as reference types . |
Concept : Value types store their values directly ( Represents actual data ), Reference types store references to their values ( Express Points to... Stored in the memory heap Pointers and references to data )
Base class : Value types are implicitly derived from System.ValueType, The reference type base class is Object
Storage : The value type is stored in the memory stack , Fast access , Stack memory is automatically released ;
Data of reference type is stored in memory heap , The memory unit stores the address stored in the heap , Slow access , Heap memory is .Net Species GC( Garbage collection mechanism ) To automatically release
premium :
- After value type variable declaration , Whether assigned or not , The compiler allocates memory for it .
- Reference type when declaring a class , Only a small piece of memory is allocated in the stack to accommodate an address , At this time, there is no memory space allocated on the heap . When using new When creating an instance of a class , Allocate space on the heap , And save the address of the space on the heap to the small space allocated on the stack .
- Instances of value types are usually allocated on the thread stack ( Static allocation ), But in some cases it can be stored in the heap .
- Objects of reference type are always allocated in the process heap ( Dynamic allocation )
The amount of space allocated by the value type in the stack varies depending on the variable type ;
The reference type has the same space in the stack ;

边栏推荐
- Ecological Wanli database and Westone completed compatible certification to jointly build a network security ecosystem
- 跟循泰国国内游宣传曲MV,像本地人一样游曼谷
- 这两所985大学,共享同一位校长!校方:属实
- Based on your work experience, talk about the quality system construction in software testing
- Meta 称英国安全法将“扫描所有私人信息”,有侵犯用户隐私风险
- halcon原理:相关性匹配
- Stimulsoft Ultimate Reports 2022.3.1
- Unity学习Day14--协程和WWW
- An idea of using keep alive to cache data in vue3 form pages
- TT-SLAM:用于平面环境的密集单目SLAM(IEEE 2021)
猜你喜欢

20年上海站D题Walker(二分,简洁)

冷板式、浸没式、喷淋式液冷散热能否引领高性能计算发展?

halcon原理:相关性匹配
![解决“Thread 1: “-[*.CollectionNormalCellView isSelected]: unrecognized selector sent to instance 0x7f”](/img/35/65511c49eca5ae8a1896d776b479d9.jpg)
解决“Thread 1: “-[*.CollectionNormalCellView isSelected]: unrecognized selector sent to instance 0x7f”

夏日炎炎玩转新加坡:盘点室内景点和夜游好去处

What if the test time is not enough?

Qt5 knowledge: some key points of signals and slots

Excel-vba quick start (I. macros, VBA, procedures, types and variables, functions)

安装Rstudio Desktop和Rstudio Server免费版本
![Halcon principle: one dimensional function_ 1D type [1]](/img/ab/c0aee923fd0a9dd8a52b8cf31a6cd7.png)
Halcon principle: one dimensional function_ 1D type [1]
随机推荐
UI framework
[no title] 2022 pressure pipeline patrol inspection and maintenance test questions and online simulation test
ROS知识:librviz库的调用实践
华为云GaussDB重磅发布HTAP商用,定义云原生数据库2.0新范式
How should enterprises conduct efficient IT operation and maintenance management?
如何卸载Gazebo与重装
MySQL使用ReplicationConnection导致的连接失效分析与解决
QT knowledge: detailed explanation of view frame qgraphicswidget
一个 BUG 开发表示用户不会这样操作,无需修复,测试人员如何应对?
Excel-VBA 快速上手(一、宏、VBA、过程、类型与变量、函数)
Machine Learning Series 5: distance space (1)
Unity小需求——简单实现仿王者钻石夺宝(单抽)
SQL adds the problem of duplicate table records.
冷板式、浸没式、喷淋式液冷散热能否引领高性能计算发展?
ROS knowledge: point cloud files PCD format
Ros2 knowledge (6): principle and practice of coordinate object TF
判断测试结束的标准有哪些?
对象池框架
09 -- palindrome pair
QT knowledge: using the qgraphicspixmapitem class