/// <summary> /// 返回循环访问对象的枚举数 /// </summary> /// <returns></returns> internal void Foreach(Action <string> action) { string[] tempList; _indexHashSet.CopyTo(out tempList, 0); foreach (var str in tempList) { action(str); } ; }
public void THashSet_Equals_Primitive_Test() { const int value = 1; var hashSet = new THashSet <int> { value }; Assert.IsTrue(hashSet.Contains(value)); hashSet.Remove(value); Assert.IsTrue(hashSet.Count == 0); hashSet.Add(value); Assert.IsTrue(hashSet.Contains(value)); hashSet.Clear(); Assert.IsTrue(hashSet.Count == 0); var newArr = new int[1]; hashSet.Add(value); hashSet.CopyTo(newArr, 0); Assert.IsTrue(newArr.Contains(value)); var en = hashSet.GetEnumerator(); en.MoveNext(); Assert.IsTrue((int)en.Current == value); using (var ien = ((IEnumerable <int>)hashSet).GetEnumerator()) { ien.MoveNext(); Assert.IsTrue(ien.Current == value); } }