当前位置:网站首页>C#学习一:值类型与引用类型
C#学习一:值类型与引用类型
2022-06-29 15:28:00 【我是赵某人】
一.C#中常见的值类型和引用类型
1.值类型:
- 所有数值类型
- 字符Char类型
- bool类型
- 结构体Struct
- 枚举enum
1.引用类型:
- 类
- 数组
- 委托
- 接口
- string字符串
二.值类型和引用类型的区别
- 引用类型在堆中分配内存,值类型在栈分配内存
- 将引用类型的的变量赋值给另一个引用类型的变量只复制内存地址,值类型会逐字段拷贝
- 引用类型的内存回收由GC回收,值类型的内存会在作用域结束时,自动释放
- 引用类型继承自System.Object,值类型继承自System.ValueType(注意:而 System. ValueType
又继承自 System.Object)
三.值类型和引用类型在内存中的实例
1.值类型内存中的实例:使用结构体来说明
2.引用类型内存中的实例:使用类来说明

四.值类型和引用类型在代码中拷贝实例
值类型拷贝实例:
引用类型拷贝实例:
边栏推荐
- 欧标插头EN50075测试项目
- 无意发现的【TiDB缓存表】,竟能解决读写热点问题
- Google 软件版本经历周期
- MCS: discrete random variable Poisson distribution
- MySQL为什么选择B+树存储索引
- CKS CKA ckad change terminal to remote desktop
- LeetCode-1188. Designing finite blocking queues
- Bash summary online log
- File常用工具类, 流相关运用 (记录)
- JS will have variable promotion and function promotion
猜你喜欢

postgresql源码学习(24)—— 事务日志⑤-日志写入WAL Buffer

MCS: discrete random variables - geometric distribution

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

Basic composition of radar

12.udp protocol -bite

89.(cesium篇)cesium聚合图(自定义图片)

For example, the visual appeal of the live broadcast of NBA Finals can be seen like this?

Chapter IX app project test (4) test tools

PostgreSQL source code learning (24) -- transaction log ⑤ - log writing to wal buffer

GWD: rotating target detection based on Gaussian Wasserstein distance | ICML 2021
随机推荐
89.(cesium篇)cesium聚合图(自定义图片)
绑定证券账户到同花顺安全吗?哪家券商开户后可以绑定同花顺
Dynamically listening for DOM element height changes
阿里云体验有奖:使用PolarDB-X与Flink搭建实时数据大屏
I am 35 years old. Can I change my career to be a programmer?
CKS CKA ckad change terminal to remote desktop
从雷达回波中可获取的信息
postgresql源码学习(25)—— 事务日志⑥-等待日志写入完成
Why MySQL chooses b+ tree to store indexes
服务器的数据库连不上了【服务已起、防火墙已关、端口已开、netlent 端口不通】
明德扬XILINX-K7-325T/410T核心板数据手册
雷达相关内容简介
Introduction to radar related contents
SSL V**技术原理
Several imaging modes of polarimetric SAR
Kotlin annotation declaration and use
Rust Basics
Mingdeyang xilinx-k7-325t/410t core board data manual
postgresql源码学习(23)—— 事务日志④-日志组装
About sql+nosql: newsql database