title: How to use new operator with a template in C#
body: <p>I'm trying to figure out how to use templates in C#. I wrote this:</p>
  
  <pre><code>public static List&lt;TValue&gt; deepCopyList&lt;TValue&gt;(List&lt;TValue&gt; src)
  {
      List&lt;TValue&gt; arr = new List&lt;TValue&gt;();
  
      for (int i = 0; i &lt; src.Count; i++)
      {
          arr.Add(new TValue(src[i]));   //Error on this line
      }
  
      return arr;
  }
  </code></pre>
  
  <p>But I get an error:</p>
  
  <blockquote>
    <p>error CS0304: Cannot create an instance of the variable type 'TValue'
    because it does not have the new() constraint</p>
  </blockquote>