找到关于编程的34423 篇文章
170 次浏览
要检查一个哈希表是否等于另一个哈希表,代码如下所示:示例 在线演示 using System; using System.Collections; public class Demo { public static void Main(){ Hashtable hash1 = new Hashtable(); hash1.Add("1", "Kevin"); hash1.Add("2", "Steve"); hash1.Add("3", "Tim"); hash1.Add("4", "Gary"); hash1.Add("5", "Kevin"); hash1.Add("6", "Steve"); hash1.Add("7", "Tom"); hash1.Add("8", "Stephen"); Console.WriteLine("HashSet1..."); ICollection key = hash1.Keys; foreach (string k in key) { ... 阅读更多
83 次浏览
要检查HashSet是否是指定集合的子集,代码如下所示:示例 在线演示 using System; using System.Collections.Generic; public class Demo { public static void Main(){ HashSet set1 = new HashSet(); set1.Add("EF"); set1.Add("OP"); Console.WriteLine("HashSet1中的元素"); foreach(string val in set1){ Console.WriteLine(val); } HashSet set2 = new HashSet(); set2.Add("KL"); set2.Add("MN"); set2.Add("OP"); set2.Add("QR"); Console.WriteLine("HashSet2中的元素"); ... 阅读更多
276 次浏览
要检查两个BitArray对象是否相等,代码如下所示:示例 在线演示 using System; using System.Collections; public class Demo { public static void Main(){ BitArray arr1 = new BitArray(2); BitArray arr2 = new BitArray(2); arr1[0] = false; arr1[1] = true; Console.WriteLine("BitArray1中的元素..."); foreach (bool res in arr1){ Console.WriteLine(res); } arr2[0] = false; arr2[1] = true; Console.WriteLine("BitArray2中的元素..."); foreach ... 阅读更多
89 次浏览
要获取StringDictionary中的键集合,代码如下所示:示例 在线演示 using System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main(){ StringDictionary strDict1 = new StringDictionary(); strDict1.Add("U", "Electronics"); strDict1.Add("V", "Toys"); strDict1.Add("W", "Books"); strDict1.Add("X", "Accessories"); Console.WriteLine("StringDictionary1元素..."); foreach(DictionaryEntry d in strDict1){ Console.WriteLine(d.Key + " " + d.Value); } Console.WriteLine("StringDictionary1是否包含键G? "+strDict1.ContainsKey("G")); StringDictionary strDict2 = new ... 阅读更多
93 次浏览
要检查StringDictionary是否包含特定值,代码如下所示:示例 在线演示 using System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main(){ StringDictionary strDict1 = new StringDictionary(); strDict1.Add("A", "John"); strDict1.Add("B", "Andy"); strDict1.Add("C", "Tim"); strDict1.Add("D", "Ryan"); strDict1.Add("E", "Kevin"); strDict1.Add("F", "Katie"); strDict1.Add("G", "Brad"); Console.WriteLine("StringDictionary1元素..."); foreach(DictionaryEntry d in strDict1){ Console.WriteLine(d.Key + " " + d.Value); } ... 阅读更多
100 次浏览
要检查StringDictionary是否包含特定键,代码如下所示:示例 在线演示 using System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main(){ StringDictionary strDict1 = new StringDictionary(); strDict1.Add("A", "John"); strDict1.Add("B", "Andy"); strDict1.Add("C", "Tim"); strDict1.Add("D", "Ryan"); strDict1.Add("E", "Kevin"); strDict1.Add("F", "Katie"); strDict1.Add("G", "Brad"); Console.WriteLine("StringDictionary1元素..."); foreach(DictionaryEntry d in strDict1){ Console.WriteLine(d.Key + " " + d.Value); } ... 阅读更多
133 次浏览
要检查两个SortedSet对象是否相等,代码如下所示:示例 在线演示 using System; using System.Collections.Generic; public class Demo { public static void Main(){ SortedSet set1 = new SortedSet(); set1.Add(100); set1.Add(200); set1.Add(300); set1.Add(400); Console.WriteLine("SortedSet1中的元素..."); foreach (int res in set1) { Console.WriteLine(res); } Console.WriteLine("SortedSet1是否包含元素400? = "+set1.Contains(400)); SortedSet set2 = new SortedSet(); set2.Add(100); ... 阅读更多
236 次浏览
要检查哈希表是否包含特定键,代码如下所示:示例 using System; using System.Collections; public class Demo { public static void Main() public static void Main(){ Hashtable hash = new Hashtable(); hash.Add("One", "Katie"); hash.Add("Two", "John"); hash.Add("Three", "Barry"); hash.Add("Four", "Mark"); hash.Add("Five", "Harry"); hash.Add("Six", "Nathan"); hash.Add("Seven", "Tom"); hash.Add("Eight", "Andy"); hash.Add("Nine", "Illeana"); hash.Add("Ten", "Tim"); Console.WriteLine("哈希表键值对..."); ... 阅读更多
90 次浏览
要检查哈希表是否为只读,代码如下所示:示例 在线演示 using System; using System.Collections; public class Demo { public static void Main(){ Hashtable hash = new Hashtable(); hash.Add("One", "Katie"); hash.Add("Two", "John"); hash.Add("Three", "Barry"); hash.Add("Four", ""); hash.Add("Five", "Harry"); hash.Add("Six", "F"); hash.Add("Seven", "Tom"); hash.Add("Eight", "Andy"); hash.Add("Nine", "I"); hash.Add("Ten", "Tim"); Console.WriteLine("哈希表键值对..."); foreach(DictionaryEntry entry in hash){ ... 阅读更多
126 次浏览
要检查SortedSet是否包含特定元素,代码如下:示例 在线演示使用 System; using System.Collections.Generic; public class Demo { public static void Main(){ SortedSet
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C语言编程
C++
C#
MongoDB
MySQL
Javascript
PHP