title: Why do I get "error: ... must be a reference type" in my C# generic method?
body: <p>In various database tables I have both a property and a value column. I'm using Linq to SQL to access the database.</p>
  
  <p>I'm writing a method which returns a dictionary containing the properties/values retrieved from the given database table:</p>
  
  <pre><code>private static Dictionary&lt;string, string&gt; GetProperties&lt;T&gt;(Table&lt;T&gt; table)
  {
      Dictionary&lt;string, string&gt; properties = new Dictionary&lt;string, string&gt;();
  
      foreach (var row in table)
      {
          properties[row.Property]=row.Value;
      }
  
      return properties;
  }
  </code></pre>
  
  <p>Upon compiling, I get:</p>
  
  <blockquote>
    <p><code>Error 1 The type 'T' must be a reference type in order to use it as parameter 'TEntity' in the generic type or method 'System.Data.Linq.Table&lt;TEntity&gt;'</code></p>
  </blockquote>
  
  <p>I've tried searching for this error message without luck.</p>
  
  <p>Searching StackOverflow, this question seems similar, though regarding a parameter List: <a href="https://stackoverflow.com/questions/1633690/generic-listt-as-parameter-on-method">Generic List&lt;T&gt; as parameter on method</a> - though the parameter still isn't a reference type in the answers to that question, either.</p>
  
  <p>Reading the C# Programming Guide on MSDN: <a href="http://msdn.microsoft.com/en-us/library/twcad0zb(VS.80).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/twcad0zb(VS.80).aspx</a> I see their examples all pass the parameters by reference. However, I can't see how to pass by reference in my particular case, since the generic type is just for specifying the generic type of Table.</p>
  
  <p>Any pointers would be much appreciated.</p>
  
  <p>PS: Appologies if it takes time for me to accept an answer, as this feature is currently not accessible (I'm blind and use a screen reader).</p>