问题描述
嗨大家好,
考虑以下代码行:
地址addr = ei.Address;
其中ei是一个具有地址
类型属性的类的实例。
问题是上述任务中发生了什么?与C / C ++的
不同,似乎上面的代码指示编译器将addr变量指向
ei.Address已经
驻留,即,它以某种方式指向ei.Address。因此,对addi变量的任何
修改都会立即应用于ei.Address。
嗯,这是对的吗?或者,我错过了什么?
任何帮助都将受到高度赞赏,
干杯,
Mehdi
Hi folks,
Consider the following line of code:
Address addr = ei.Address;
where ei is an instance of a class that has got a property of Address
type.
The question is that what is happening in the above assignment? Unlike
the C/C++, it seems that the above code instructs the compiler to point
the addr variable to the same location where ei.Address already
resides, i.e, it''s somehow a pointer to the ei.Address. Therefore, any
modification on addr variable is instantly applied to the ei.Address.
Well, is this right? or, am I missing something?
Any help would be highly appreciated,
Cheers,
Mehdi
推荐答案
在托管世界中,它被称为引用,但是,这几乎是什么
发生如果地址是一个类;你在帖子中指出ei是一个类的一个
实例,你对地址一无所知。
如果Address不是一个类而是一个结构以上是不正确的。
-
-
Ignacio Machin,
ignacio.machin AT dot。 state.fl.us
佛罗里达州交通局
In managed world it''s called reference but yes, that''s pretty much what
happens IF Address IS A class ; in your post you especify that ei is an
instance of a class, you say nothing about Address.
If Address is not a class but a struct the above is not true.
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
这篇关于参考文献与副本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!