当前位置:网站首页>C # learning 1: value type and reference type
C # learning 1: value type and reference type
2022-06-29 15:46:00 【This is Zhao】
One .C# Common value types and reference types in
1. Value type :
- All numeric types
- character Char type
- bool type
- Structure Struct
- enumeration enum
1. Reference type :
- class
- Array
- entrust
- Interface
- string character string
Two . Difference between value type and reference type
- Reference types allocate memory in the heap , Value types allocate memory on the stack
- Assigning a variable of a reference type to a variable of another reference type only copies the memory address , Value types are copied field by field
- Memory reclamation for reference types is handled by GC Recycling , The memory of the value type will be at the end of the scope , Automatic release
- Reference types inherit from System.Object, Value types inherit from System.ValueType( Be careful : and System. ValueType
And inherit from System.Object)
3、 ... and . Instances of value types and reference types in memory
1. Value type instance in memory : Use structure to illustrate 
2. Instance in reference type memory : Use classes to describe

Four . Value types and reference types copy instances in code
Value type copy instance :
Reference type copy instance :
边栏推荐
猜你喜欢

13.TCP-bite

分页sql(rownum、row_number、dense_rank、rank)

MCS: multivariate random variable - discrete random variable

LeetCode-234-回文链表

Imgutil image processing tool class, text extraction, image watermarking

three.js和高德地图结合引入obj格式模型-效果演示

File common tool class, stream related application (record)

Mingdeyang xilinx-k7-325t/410t core board data manual

Informatics Olympiad all in one 2061: trapezoidal area

Motion capture system for apple picking robot
随机推荐
C#学习二:堆和栈
stlink故障修复
89.(cesium篇)cesium聚合图(自定义图片)
File常用工具類, 流相關運用 (記錄)
.NET程序配置文件操作(ini,cfg,config)
阿里云体验有奖:使用PolarDB-X与Flink搭建实时数据大屏
Scroll, do you understand?
PostgreSQL source code learning (25) -- transaction log ⑥ - wait for log writing to complete
PostgreSQL source code learning (23) -- transaction log ④ - log assembly
Imgutil image processing tool class, text extraction, image watermarking
Rust基础知识
Development and application of NFT chain Games: Six noteworthy NFT trends in 2022
数据挖掘复习
深度学习遥感数据集
中序和后序遍历构建二叉树[递归划分区间与回溯拼接子树+中后序和中前序的相似与不同]
明德扬XILINX-K7-325T/410T核心板数据手册
Excel中构建SQL语句
c#Sqlite类库
极化SAR地表分类
关于SQL+NoSQL : NewSQL数据库