一切都是对象... [英] everything is an object...

查看:138
本文介绍了一切都是对象...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.是诸如int之类的基元(在幕后是结构,即System.Int32)吗?因为基元是通过值传递的,所以它与对象是通过引用传递的事实相矛盾?请任何人启发我.谢谢.

in c#. are primitives such as int (which behind-the-scenes are structs i.e. System.Int32) therefore objects? since primitives are pass by value, it contradicts the fact that objects are pass by reference? please anyone enlighten me. thanks.

推荐答案

swjam写道:

与事实相矛盾那个对象是通过引用传递的?

it contradicts the fact that objects are pass by reference?



好吧,实际上所有东西都是通过值传递的(除非您另外指定).当您传递对象时,您实际上是在将引用传递给该对象,并且由于引用是一种值类型,因此它会按值传递,即复制引用的值.



Well, actually everything is passed by value (unless you specify otherwise). When you pass an object you are actually passing the reference to the object, and as the reference is a value type it''s passed by value, i.e. the value of the reference is copied.


这篇关于一切都是对象...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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