title: Can't add null to list of nullables
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1911577/adding-null-to-a-listbool-cast-as-an-ilist-throwing-an-exception">Adding null to a List&lt;bool?&gt; cast as an IList throwing an exception.</a>  </p>
  </blockquote>
  
  
  
  <pre><code>List&lt;int?&gt; listONullables = new List&lt;int?&gt;();
  IList degenericed = listONullables;
  
  // This works fine
  listONullables.Add(null); 
  
  // Run time exception:
  // "The value "" is not of type "System.Nullable`1[System.Int32]"
  // and cannot be used in this generic collection.  Parameter name: value"
  degenericed.Add(null);
  
  // Also does not work.  Same exception
  degenericed.Add((int?)null);
  
  // Also does not work
  // EDIT: I was mistaken, this does work
  degenericed.Add((int?)1);
  
  // Also does not work
  // EDIT: I was mistaken, this does work
  degenericed.Add(1);
  </code></pre>
  
  <p>See the comments in the above code.</p>
  
  <p>I sort of understand the reasons for this (when you cast away the generics the runtime does the best it can with limited information).  I'm just wondering if there's a way around this, even if it's a bit of a hack.</p>
  
  <p>The problem sprang up when I tried having the generic version of a function use the same private implementation as a non generic version, so I can work around it if necessary (have two very similar implementations), but obviously it's better if I can figure this out.</p>
  
  <p>EDIT: The last two entries I have above do NOT fail like I originally said.  But the first two do.  I've added comments to that effect in the code above.</p>