c# value vs. reference

I'm just beginning C#. My book states that a "struct Foo" will perform myFoo1 = myFoo2 as copy by value.
But with a "class Foo", myFoo1 = myFoo2 will copy by reference... but doesn't quite explain why.

Is there a technical reason for this?

(Also: do people even use structs that often in C# in the professional world?)
structs in C# are certainly rarely used to avoid to permanently copy the content.

copy by reference means basically copying the pointer to that object.

Is there a technical reason for this?
The reason for this is the garbage collector. You cannot dereference an object controlled by the garbage collector (copy the content is rather difficult). Hence structs are not controlled and cannot be passed as a reference.
Topic archived. No new replies allowed.