title: Is C# string passed by value or passed by reference?
body: <pre><code>namespace Test
  {
    class Program
    {
      static void Main(string[] args)
      {
        A a = new A();
        a.MyString = "Metallica ";
        PrintA(a);
        Console.WriteLine(a.MyString);
  
        string name = "Linkin ";
        Print(name);
        Console.WriteLine(name);
  
        Console.ReadLine();
      }
  
      static void PrintA(A a)
      {
        a.MyString = a.MyString + "Rocks";
        Console.WriteLine(a.MyString);
      }
  
      static void Print(string text)
      {
        text = text + "Park";
        Console.WriteLine(text);
      }
    }
  
    class A
    {
      public string MyString { get; set; }
    }
  
  }
  </code></pre>
  
  <p>Output:</p>
  
  <blockquote>
    <p>Metallica Rocks</p>
    
    <p>Metallica Rocks</p>
    
    <p>Linkin Park</p>
    
    <p>Linkin</p>
  </blockquote>
  
  <p>My question here is that, if string is a reference type (i.e. a class) then why does it not change value of the variable <em>name</em> after the method <em>Print()</em> is called, like it happens for reference variable <em>a</em>'s member <em>MyString</em>.</p>