The right way to think about this is to use ref / out if you want to create an alias for the variable . That is, when you say:
void M(ref int x) { x = 10; } ... int q = 123; M(ref q);
what do you say: "x is another name for the q variable." Any changes in the content for x changes q and any changes in the contents of q change x, since x and q are just two names for the same storage location.
Note that this is completely different from two variables related to the same object:
object y = "hello"; object z = y;
Here we have two variables, each variable has one name, each variable refers to one object, and two variables refer to the same object. In the previous example, we have only one variable with two names.
It is clear?
source share