The only .NET language i know is C#. In C# you can write lhs=rhs and if its a struct it will copy by value, if a class it copies by reference.
Does the .NET CLI support doing either on any type of object? Can i create a struct Pt { int x, y; } and do something like
Pt pt
var pt_ref=&pt
pt_ref.x=99 //pt.x is now 99
var pt_cpy=pt
pt_cpy.x=88 //nothing else has changed
At the IL level references to value types are a possibility. C# disallows them (except in parameters, using the
refkeyword), but in C++/CLI you can write your example:However, the other way around is not possible. If you have a reference type, and you create a copy of that, you create a copy of the reference itself, not of the referenced object. If you want to copy the referenced object, you need to write a function to copy it yourself.