title: C# fields not retaining values when stored in arrays
body: <p>I have a situation in my program where I have around 20 fields. All of them are strings. Now I also have an array of strings of size 20. I want to sequentially initialize those fields from the string stored inside this array. I do not want to do this:</p>
  
  <p>field1 = array[0];</p>
  
  <p>field2 = array[1];</p>
  
  <p>....</p>
  
  <p>field20 = array[19];</p>
  
  <p>So I wrote a test program like this but it doesn't work with strings. It's only working with reference types. Is there any way to do it?</p>
  
  <pre><code>public class Program
  {
      private string name;
      private string id;
  
      private void Func()
      {
          var array = new[] {name, id};
          for (int i = 0; i &lt; array.Length; i++)
          {
              array[i] = "some string";
          }
      }
  
      public static void Main(string[] args)
      {
          var p = new Program();
          p.Func();
          Console.WriteLine(p.name); // prints null
      }
  }
  </code></pre>