struct中的class在复制时指向堆中的同一个对象。
struct out
{
class in a;
}
out o1 = new out();
out o2 = o1;
o2.a与o1.a指向同一个对象。
struct中的class在复制时指向堆中的同一个对象。
struct out
{
class in a;
}
out o1 = new out();
out o2 = o1;
o2.a与o1.a指向同一个对象。
值类型的值存储在内存的栈当中;引用类型的值存储在内存的堆当中。
CLR支持两种类型:引用类型和值类型,它们的区别是在内存分配方式上的差异:引用类
,“不理解引用类型和值类型区别的程序员将会给代码引入诡异的bug和性能
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M