<p>Ideally, I'm looking for a templated logical Set class.  It would have all of the standard set operations such as Union, Intersection, Etc., and collapse duplicated items.</p>

<p>I ended up creating my own set class based on the C# Dictionary&lt;>- just using the Keys.</p>

[{'answer_id': 10459, 'author': 'Matt Hamilton', 'author_id': 615, 'author_profile': 'https://Stackoverflow.com/users/615', 'pm_score': 6, 'selected': False, 'text': '<p><a href="http://msdn.microsoft.com/en-us/library/bb359438.aspx" rel="noreferrer"><code>HashSet&lt;T&gt;</code></a> is about the closest you\'ll get, I think.</p>\n'}, {'answer_id': 10460, 'author': 'Dale Ragan', 'author_id': 1117, 'author_profile': 'https://Stackoverflow.com/users/1117', 'pm_score': 3, 'selected': False, 'text': '<p>No, there is not one natively in the framework.  There is an open source implementation that most projects use, (i.e. nHibernate) called Iesi.Collections.  Here\'s a CodeProject article about it:</p>\n\n<p><a href="http://www.codeproject.com/KB/recipes/sets.aspx" rel="noreferrer">http://www.codeproject.com/KB/recipes/sets.aspx</a></p>\n'}, {'answer_id': 10470, 'author': 'lomaxx', 'author_id': 493, 'author_profile': 'https://Stackoverflow.com/users/493', 'pm_score': 3, 'selected': False, 'text': '<p>I don\'t think c# has anything built in, but I know there are a couple of implementations floating around on the net. There are also some good articles around on this sort of thing:</p>\n\n<p><a href="http://msdn.microsoft.com/en-us/library/ms379575(VS.80).aspx" rel="nofollow noreferrer">This is part 6</a> of a series on efficiently representing data structure. This part focuses on representing sets in C#.</p>\n\n<p><a href="http://www.codeproject.com/KB/collections/SetCollectionsForCSharp.aspx" rel="nofollow noreferrer">An implementation</a> of a set collection <br>\n<a href="http://www.codeproject.com/KB/recipes/Types_Set.aspx" rel="nofollow noreferrer">An implementation</a> of a set class<br>\n<a href="http://www.codeproject.com/KB/recipes/yaset.aspx" rel="nofollow noreferrer">Yet another implementation</a> of a set class</p>\n\n<p>And finally...</p>\n\n<p>I\'ve actually used <a href="http://www.codeproject.com/KB/recipes/sets.aspx" rel="nofollow noreferrer">this library</a> myself as the basis of a set implementation that I did a year or so ago.</p>\n'}, {'answer_id': 10493, 'author': 'Brad Leach', 'author_id': 708, 'author_profile': 'https://Stackoverflow.com/users/708', 'pm_score': 4, 'selected': False, 'text': '<p>The best set implementation I have seen is part of the wonderful Wintellect\'s Power Collections:\n<a href="http://www.codeplex.com/PowerCollections" rel="noreferrer">http://www.codeplex.com/PowerCollections</a>.</p>\n\n<p>The set implementation can be found here:<br />\n<a href="http://www.codeplex.com/PowerCollections/SourceControl/FileView.aspx?itemId=101886&amp;changeSetId=6259" rel="noreferrer">http://www.codeplex.com/PowerCollections/SourceControl/FileView.aspx?itemId=101886&amp;changeSetId=6259</a><br />\nIt has all the expected set operations (union, intersect, etc).</p>\n\n<p>Hope this helps!</p>\n'}, {'answer_id': 199988, 'author': 'Stephen franklin', 'author_id': 27714, 'author_profile': 'https://Stackoverflow.com/users/27714', 'pm_score': 3, 'selected': False, 'text': '<p>Have you checked out the <a href="http://msdn.microsoft.com/en-us/library/bb397727.aspx" rel="noreferrer">HashSet</a> in 3.5?</p>\n'}, {'answer_id': 50264359, 'author': 'dharmatech', 'author_id': 268581, 'author_profile': 'https://Stackoverflow.com/users/268581', 'pm_score': 1, 'selected': False, 'text': '<p>Here\'s a simple implementation:</p>\n\n<pre><code>public sealed class MathSet&lt;T&gt; : HashSet&lt;T&gt;, IEquatable&lt;MathSet&lt;T&gt;&gt;\n{\n    public override int GetHashCode() =&gt; this.Select(elt =&gt; elt.GetHashCode()).Sum().GetHashCode();\n\n    public bool Equals(MathSet&lt;T&gt; obj) =&gt; SetEquals(obj);\n\n    public override bool Equals(object obj) =&gt; Equals(obj as MathSet&lt;T&gt;);\n\n    public static bool operator ==(MathSet&lt;T&gt; a, MathSet&lt;T&gt; b) =&gt;\n        ReferenceEquals(a, null) ? ReferenceEquals(b, null) : a.Equals(b);\n\n    public static bool operator !=(MathSet&lt;T&gt; a, MathSet&lt;T&gt; b) =&gt; !(a == b);\n}\n</code></pre>\n\n<p>Example usage:</p>\n\n<pre><code>var a = new MathSet&lt;int&gt; { 1, 2, 3 };\nvar b = new MathSet&lt;int&gt; { 3, 2, 1 };\n\nvar c = a.Equals(b);                        // true\n\nvar d = new MathSet&lt;MathSet&lt;int&gt;&gt; { a, b }; // contains one element\n\nvar e = a == b;                             // true\n</code></pre>\n\n<p>See <a href="https://stackoverflow.com/questions/47688779/set-class-with-mathematical-set-equality-by-default">this question</a> for why this approach was considered over <code>HashSet</code>.</p>\n'}]
['https://Stackoverflow.com/questions/10458', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/']