值类型和引用类型之间的基本区别 [英] basic difference between value types and reference types

查看:213
本文介绍了值类型和引用类型之间的基本区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
什么是C#值类型和引用类型之间的差异?

什么是价值观类型和rereference类型

what are the basics differences between values types and rereference types

推荐答案

考虑两个变量:

SomeReferenceType x;
SomeValueType y;



的值x 是一个参考 - 它要么是空或一个对象,它是本身 SomeReferenceType 的实例或派生类的引用。的 的值x 不是,本身的对象。

The value of x is a reference - it will either be null or a reference to an object which is itself an instance of SomeReferenceType or a derived class. The value of x is not, in itself, the object.

价值的是数据本身 - 如果 SomeValueType 有三个字段的 y中的值将直接包含这些字段

The value of y is the data itself - if SomeValueType has three fields, the value of y will directly contain those fields.

这是一个非常简短的总结 - 看的Eric利珀特的博客帖子大约值类型并的我的更多信息,文章。 (您可能也有兴趣在我了解参数传递这与的文章,但并不完全一样。)

That's a very brief summary - see Eric Lippert's blog post about value types and my article for more information. (You might also be interested in my article about parameter passing which is related, but not quite the same.)

这篇关于值类型和引用类型之间的基本区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆