title: Are there any collections in .NET that prevent null entries?
body: <p>I'm specifically thinking about a collection that fulfills the contract of a set, but I think the question can apply to any kind. Are there collections in the .NET framework that prevent null entries? The specific behavior I want is this:</p>
  
  <pre><code>var set = new HashSet&lt;object&gt;();
  bool added = set.Add(null);
  Console.WriteLine(added); // prints "False"
  </code></pre>
  
  <p>This isn't the behavior of the built-in <code>HashSet&lt;T&gt;</code>. Are there any collections that do have this (or similar) behavior, or am I better off rolling my own? If the latter, what's the best way to go about it? Should I inherit directly from <code>HashSet&lt;T&gt;</code> or just wrap it?</p>
  
  <p>EDIT: To be clear, this is just idle wondering. Mostly because I can't think of any reason I'd ever <em>want</em> to allow <code>null</code> into a set of objects. I don't have any particular need for this.</p>