设置一个类型的引用类型设置为null不会影响复制类型? [英] Setting a type reference type to null doesn't affect copied type?
本文介绍了设置一个类型的引用类型设置为null不会影响复制类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么这会产生0?
object a = 0;
object b = a;
a = null;
Console.WriteLine(b.ToString()); // Produces "0"
Console.Read();
不b指向了同一个位置,并设置=空有效地使b空?
Doesn't b point to the same location and setting a = null effectively makes b null?
推荐答案
一张图片胜过千言万语:
A picture is worth a thousand words:
这篇关于设置一个类型的引用类型设置为null不会影响复制类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文