title: Type 'string' as an argument in C# function
body: <p>The <code>string</code> type in C# is a reference type, and passing a reference type argument by value copies the reference so that I don't need to use the <code>ref</code> modifier. However, I need to use the <code>ref</code> modifier for modifying the input <code>string</code>. Why is this?</p>
  
  <pre><code>using System;
  
  class TestIt
  {
      static void Function(ref string input)
      {
          input = "modified";
      }
  
      static void Function2(int[] val) // Don't need ref for reference type
      {
          val[0] = 100;
      }
  
      static void Main()
      {
          string input = "original";
          Console.WriteLine(input);
          Function(ref input);      // Need ref to modify the input
          Console.WriteLine(input);
  
          int[] val = new int[10];
          val[0] = 1;
          Function2(val);
          Console.WriteLine(val[0]);
      }
  }
  </code></pre>