当前位置:网站首页>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 :
边栏推荐
- Training mode of deep learning network
- Rust基础知识
- File常用工具類, 流相關運用 (記錄)
- 遥感典型任务分析
- Middle order and post order traversal to construct binary tree [recursive partition interval and backtracking splicing subtree + similarity and difference between middle post order and middle pre orde
- EasyGBS调用获取实时快照接口时,出现白色方块该如何解决?
- swift JSONSerialization
- Alibaba cloud experience Award: use polardb-x and Flink to build a large real-time data screen
- Is there any lack of dependence? An error is reported when flinksql is packaged and running, but there is no problem when the local idea runs. Solve it. Thanks
- PostgreSQL source code learning (23) -- transaction log ④ - log assembly
猜你喜欢
随机推荐
postgresql源码学习(24)—— 事务日志⑤-日志写入WAL Buffer
ImgUtil 图片处理工具类,文字提取,图片水印
C#学习二:堆和栈
C language big job - Matching System
12.UDP协议-bite
SSL v** technical principle
Why MySQL chooses b+ tree to store indexes
LeetCode笔记:Biweekly Contest 81
C语言大作业——匹配系统
LeetCode-1188. 设计有限阻塞队列
kotlin 注解聲明與使用
MySQL JSON array operation JSON_ array_ append、json_ array_ insert
LeetCode笔记:Weekly Contest 299
PostgreSQL source code learning (25) -- transaction log ⑥ - wait for log writing to complete
雷达相关内容简介
three.js和高德地图结合引入obj格式模型-效果演示
Taro2.* 小程序配置分享微信朋友圈
【力扣10天SQL入门】Day7+8 计算函数
Dynamically listening for DOM element height changes
Mysql database naming conventions PDF







