title: Why can I not return a reference to a dictionary value?
body: <pre><code>public class PropertyManager
  {
      private Dictionary&lt;ElementPropertyKey, string&gt; _values = new Dictionary&lt;ElementPropertyKey, string&gt;();
      private string[] _values2 = new string[1];
      private List&lt;string&gt; _values3 = new List&lt;string&gt;();
      public PropertyManager()
      {
          _values[new ElementPropertyKey(5, 10, "Property1")] = "Value1";
          _values2[0] = "Value2";
          _values3.Add("Value3");
      }
  
      public ref string GetPropertyValue(ElementPropertyKey key)
      {
          return ref _values[key]; //Does not compile. Error: An expression cannot be used in this context because it may not be returned by reference.         
      }
  
      public ref string GetPropertyValue2(ElementPropertyKey key)
      {
          return ref _values2[0]; //Compiles
      }
  
      public ref string GetPropertyValue3(ElementPropertyKey key)
      {
          return ref _values3[0]; //Does not compile. Error: An expression cannot be used in this context because it may not be returned by reference.
      }
  }
  </code></pre>
  
  <p>In the above example GetPropertyValue2 compiles, but GetPropertyValue and GetPropertyValue3 do not.
  What is wrong with returning a value from a dictionary or list as reference, while it does work for an array?</p>