Passing by value and reference C#
<p>I know that values sent to a function are by default passed as value and the method receives a copy of the variable.  I know that when a variable is passed by reference the method can change the value of the variables from it was called.  That being said, can someone help explain what's going on in these simple illustrations? thanks in advance.  Are expressions passed by reference, I guess?</p>

<pre><code>using System;
class Program
{
    static void Main(string[] args)
    {
        int x = 2;
        int y = 20;
        Console.WriteLine(Add(x, y));
    }

    static int Add(int x, int y)
    {
        int ans = x + y;
         x = 20;
         y = 40;
       // return x+y;
         return ans;
        //returns 22
    }
}
</code></pre>

<p>and then</p>

<pre><code>using System;
class Program
{
    static void Main(string[] args)
    {
        int x = 2;
        int y = 20;
        Console.WriteLine(Add(x, y));
    }

    static int Add(int x, int y)
    {
        int ans = x + y;
         x = 20;
         y = 40;
       return x+y;
      //   return ans;
        //returns 60
    }
}
</code></pre>
