Introduction

When we writing our code, we need quite often to pass a parameter. There are different type of variables can be passed(value type, reference type, immutable reference types), and they can be pass as different kind of parameters(value parameter, reference
parameter, output parameter, parameter array). We know C# parameters are default passed by value. But note, for a reference type variable, more often people see that as passed by reference by default. In fact when we say an object is passed by refernce by
default what actually happen is "that object reference is passed by value by default" (detailed explanation please see an article here:http://www.yoda.arachsys.com/csharp/parameters.html).

Content

This sounds extramely confusing, especially when i first came to this area. Now i'll try to show this by a small example.
Here we have an int as value type:

Here we have an object of our own type:

Here the inside and outside variable reference to the same Person object. It is because the reference of the outside variable passed into the fuction, by value(easier to understant when consider the passed value is similar to a "pointer value").
Therefore, when passing a reference type parameter to a function even we didn't set the parameter as ref, the operation still can affect the underlying object.
But in some case we do want to pass an object by value. Now consider the below example:

This is not what we intented to do. We want keep the sample with a category of 'Sample Product'. To copy an object's properties we need to explicitly set every field. The copy constructor is a good way to do this. Now modify the code as below:

In this way we apparently pass an object by its value. In fact we just create a new object as a copy of that oject with the copy constructor.