❔ C# Fundamental: does setting one object to another point or copy?
this is probably a braindead question but in this code, is
anotherObject
"pointing" to someObject
(changing the instance variables of one will change the other's) or does anotherObject
copy the values of someObject
into a new object? im new to the language and trying to develop an understanding9 Replies
Yes it's pointing to it
this doesn't compile
but it would point, yes
i know it doesn't compile, i was just trying to get the point across
thank you
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
tebeco#0205
REPL Result: Success
Console Output
Compile: 602.492ms | Execution: 76.052ms | React with ❌ to remove this embed.
mtreit#6470
REPL Result: Success
Console Output
Compile: 649.891ms | Execution: 74.328ms | React with ❌ to remove this embed.
You can use ReferenceEquals if you want to see if two variables point to the same object on the heap
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.