System.Collections.Generic.HashSet
HashSet(T) クラス (System.Collections.Generic)
値のセットを表します。
HashSet コレクション型
簡単に言えば、HashSet
「値のないDictionary」ということはどうやら重複は排除されるようですね。
検証
検証してみましょう。
using System.Collections.Generic; using NUnit.Framework; namespace HashSetSample { [TestFixture] public class HashSetTest { [Test] public void Test() { HashSet<int> hashSet = new HashSet<int>() { 3, 1, 1, 2, 2 }; CollectionAssert.AreEquivalent(new int[] {1, 2, 3}, hashSet); } } }
確かに重複は排除されていますね。