c# - Are there any collections in .NET that prevent null entries? -


I'm thinking specifically about a collection that meets the contract of a set, but I think That question can make any type of application. Are there structures in the NAT framework that prevent zero entries? I want the specific behavior to be:

  var set = new hashset & lt; Object & gt; (); Bull added = set.add (empty); Console.WriteLine (added); // print "wrong"  

This built-in hashaseet and lt; T & gt; is not a behavior, is there a collection that behaves this (or similar), or am I doing better than rolling myself? If the latter, what is the best way to go about it? Do I get to HashSet & lt; T & gt; Get it directly from or simply wrap it?

EDIT: To be clear, it is simply worthless thinking mostly because I can not think of any reason because I have ever wanted to to null In the set of objects I did not have any special requirements for this.

There is no underlying class such as hashaseet and lieutenant; T & gt; except for this single behavior.

If you need this, then I recommend rolling myself. I have sub-coding HashSet & lt; T & gt; , however any method (such as add , which you want to explicitly change) is virtual because it is not really designed with sub-clinging in mind I went. This causes strange behavior because you want to hide the inherited methods.

Just a HashSet & lt; T & gt; Expose , and expose the members you need. The only real "code" you need to add is a random check on Addition Method - otherwise, simply explain all the methods passed for example.

If you want the general class, you will need to add an extra barrier to working with the class, because you want to do a redundancy test:

  Public Class ValueSet & lt; T & gt; : Iconic Lieutenant; T & G, IEInemable & lt; T & gt;, Icicle Where T: Class {Private Hasheset & lt; T & gt; HashSet = New Hashet & lt; T & gt; (); // ... Apply all required members ...  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -