当前位置:网站首页>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 ;

边栏推荐
- C#学习(高级课程)Day13——反射
- HMS core video editing service has the ability to open templates, helping users get the same cool video with one click
- Voice module: pyttsx sound change project
- Unity小需求——简单实现仿王者钻石夺宝(单抽)
- 技术分享| WVP+ZLMediaKit实现摄像头GB28181推流播放
- Halcon原理:auto_threshold算子
- 数据中台稳定性的“四高” | StartDT Tech Lab 18
- 根据你的工作经历,说说软件测试中质量体系建设
- How can testers get started quickly when they change jobs to a new company?
- Deep thinking: in-depth analysis of some scenes in Gaia Altman and the philosophy and perception reflected
猜你喜欢

Halcon principle: Auto_ Threshold operator

AssetBundle资源管理

Ros2 knowledge (6): principle and practice of coordinate object TF

详解PyQt5信号与槽的关系

The list of open source summer winners has been publicized, and the field of basic software has become a hot application this year

Localization information | aikesheng and China kefangde complete product compatibility and mutual certification

Playing in Singapore in the hot summer: an inventory of indoor attractions and good places for night trips

生态 | 万里数据库与卫士通完成兼容认证 共筑网络安全生态体系

Ablebits Ultimate Suite for Excel

Use xtradiagram Diagramcontrol for drawing and controlling process graphics
随机推荐
The list of open source summer winners has been publicized, and the field of basic software has become a hot application this year
The median annual salary exceeds 300000, and the salary of the first AI major graduate of Nanjing University is exposed
手机开户有什么风险吗?开户安全吗?
halcon原理:相关性匹配
Ablebits Ultimate Suite for Excel
ROS知识:点云文件.pcd格式
Halcon principle: Auto_ Threshold operator
Oracle数据库的主导地位被云竞争对手逐渐侵蚀
[system architecture] - five styles of software architecture
Go zero micro Service Practice Series (VI. cache consistency assurance)
这两所985大学,共享同一位校长!校方:属实
判断测试结束的标准有哪些?
2D laser Slam (using laser scan matcher)
Synergetic process
Qt5 knowledge: DNS query
如何卸载Gazebo与重装
ROS knowledge: reading point cloud data files
New project, how to ensure the coverage of the test?
<Sicily>1001. Rails
QT knowledge: QT widgets widget class [01]