找到 34423 篇文章,关于编程

检查 C# 中的哈希表是否等于另一个哈希表

AmitDiwan
更新于 2019-12-04 08:03:47

170 次浏览

要检查一个哈希表是否等于另一个哈希表,代码如下所示 - 示例 实时演示使用 System;使用 System.Collections;公共类演示 {    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) {       ... 阅读更多

检查 C# 中的 HashSet 是否是指定集合的子集

AmitDiwan
更新于 2019-12-04 08:00:02

83 次浏览

要检查一个 HashSet 是否是指定集合的子集,代码如下所示 - 示例 实时演示使用 System;使用 System.Collections.Generic;公共类演示 {    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 中的元素");   ... 阅读更多

检查 C# 中的两个 BitArray 对象是否相等

AmitDiwan
更新于 2019-12-04 07:55:59

276 次浏览

要检查两个 BitArray 对象是否相等,代码如下所示 - 示例 实时演示使用 System;使用 System.Collections;公共类演示 {    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 ... 阅读更多

获取 C# 中 StringDictionary 中的键集合

AmitDiwan
更新于 2019-12-04 07:53:04

89 次浏览

要获取 StringDictionary 中的键集合,代码如下所示 - 示例 实时演示使用 System;使用 System.Collections;使用 System.Collections.Specialized;公共类演示 {    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 ... 阅读更多

检查 C# 中的 StringDictionary 是否包含特定值

AmitDiwan
更新于 2019-12-04 07:47:23

93 次浏览

要检查 StringDictionary 是否包含特定值,代码如下所示 - 示例 实时演示使用 System;使用 System.Collections;使用 System.Collections.Specialized;公共类演示 {    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);       }   ... 阅读更多

检查 C# 中的 StringDictionary 是否包含特定键

AmitDiwan
更新于 2019-12-04 07:38:54

100 次浏览

要检查 StringDictionary 是否包含特定键,代码如下所示 - 示例 实时演示使用 System;使用 System.Collections;使用 System.Collections.Specialized;公共类演示 {    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);       }   ... 阅读更多

检查 C# 中的两个 SortedSet 对象是否相等

AmitDiwan
更新于 2019-12-04 07:34:29

133 次浏览

要检查两个 SortedSet 对象是否相等,代码如下所示 - 示例 实时演示使用 System;使用 System.Collections.Generic;公共类演示 {    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);   ... 阅读更多

检查 C# 中的哈希表是否包含特定键

AmitDiwan
更新于 2019-12-04 07:30:49

236 次浏览

要检查哈希表是否包含特定键,代码如下所示 - 示例使用 System;使用 System.Collections;公共类演示 {    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("哈希表键值对...");       ... 阅读更多

检查 C# 中的哈希表是否为只读

AmitDiwan
更新于 2019-12-04 07:26:35

90 次查看

要检查哈希表是否为只读,代码如下:示例 实时演示使用 System;使用 System.Collections;公共类 Demo {    公共静态无效 Main(){       哈希表哈希 = 新哈希表();       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("哈希表键值对...");       针对(字典条目条目在哈希中){     ... 阅读更多

检查 SortedSet 在 C# 中是否包含特定元素

AmitDiwan
更新于 2019-12-04 07:23:00

126 次查看

要检查 SortedSet 是否包含特定元素,代码如下:示例 实时演示使用 System;使用 System.Collections.Generic;公共类 Demo {    公共静态无效 Main(){       SortedSet set1 = 新 SortedSet();       set1.Add("CD");       set1.Add("CD");       set1.Add("CD");       set1.Add("CD");       Console.WriteLine("SortedSet1 中的元素...");       针对(字符串结果在 set1 中){          Console.WriteLine(res);       }       Console.WriteLine("SortedSet1 是否包含元素 DE?= " + set1.Contains("DE"));       SortedSet set2 = 新 SortedSet();       set2.Add("BC");   ... 阅读更多

广告

© . All rights reserved.