找到 2628 篇文章 关于 C#
82 次浏览
要从 HybridDictionary 中移除指定的键值对,代码如下所示:示例 在线演示using System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main() { HybridDictionary dict1 = new HybridDictionary(); dict1.Add("A", "Books"); dict1.Add("B", "Electronics"); dict1.Add("C", "Smart Wearables"); dict1.Add("D", "Pet Supplies"); dict1.Add("E", "Clothing"); dict1.Add("F", "Footwear"); Console.WriteLine("HybridDictionary1 元素..."); foreach(DictionaryEntry d in dict1) { Console.WriteLine(d.Key + " " + d.Value); } ... 阅读更多
76 次浏览
要从 StringCollection 中移除第一次出现的元素,代码如下所示:示例 在线演示using System; using System.Collections.Specialized; public class Demo { public static void Main() { StringCollection stringCol = new StringCollection(); String[] arr = new String[] { "100", "200", "100", "400", "500" }; Console.WriteLine("数组元素..."); foreach (string res in arr) { Console.WriteLine(res); } stringCol.AddRange(arr); Console.WriteLine("元素总数 = "+stringCol.Count); stringCol.Remove("100"); Console.WriteLine("现在的元素总数 = ... 阅读更多
70 次浏览
要检查 StringCollection 是否为只读,代码如下所示:示例 在线演示using System; using System.Collections.Specialized; public class Demo { public static void Main() { StringCollection stringCol = new StringCollection(); String[] arr = new String[] { "100", "200", "300", "400", "500" }; Console.WriteLine("数组元素..."); foreach (string res in arr) { Console.WriteLine(res); } stringCol.AddRange(arr); Console.WriteLine("StringCollection 是否只读? = "+stringCol.IsReadOnly); Console.WriteLine("指定的字符串是否在 StringCollection 中? = "+stringCol.Contains("800")); ... 阅读更多
70 次浏览
要检查 StringCollection 是否包含指定的字符串,代码如下所示:示例 在线演示using System; using System.Collections.Specialized; public class Demo { public static void Main() { StringCollection stringCol = new StringCollection(); String[] arr = new String[] { "100", "200", "300", "400", "500" }; Console.WriteLine("数组元素..."); foreach (string res in arr) { Console.WriteLine(res); } stringCol.AddRange(arr); Console.WriteLine("指定的字符串是否在 StringCollection 中? = "+stringCol.Contains("800")); } }输出这将产生以下 ... 阅读更多
61 次浏览
要从 ListDictionary 中移除具有指定键的条目,代码如下所示:示例 在线演示using System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main(){ ListDictionary dict1 = new ListDictionary(); dict1.Add("A", "Books"); dict1.Add("B", "Electronics"); dict1.Add("C", "Smart Wearables"); dict1.Add("D", "Pet Supplies"); dict1.Add("E", "Clothing"); dict1.Add("F", "Footwear"); Console.WriteLine("ListDictionary1 元素..."); foreach(DictionaryEntry d in dict1) { Console.WriteLine(d.Key + " " + d.Value); } ... 阅读更多
66 次浏览
要从 OrderedDictionary 中移除指定索引处的条目,代码如下所示:示例 在线演示using System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main() { OrderedDictionary dict = new OrderedDictionary(); dict.Add("A", "Books"); dict.Add("B", "Electronics"); dict.Add("C", "Smart Wearables"); dict.Add("D", "Pet Supplies"); dict.Add("E", "Clothing"); dict.Add("F", "Footwear"); Console.WriteLine("OrderedDictionary 元素..."); foreach(DictionaryEntry d in dict) { Console.WriteLine(d.Key + " " + d.Value); } ... 阅读更多
74 次浏览
要检查两个 SortedList 对象是否相等,代码如下所示:示例 在线演示using System; using System.Collections; public class Demo { public static void Main(String[] args) { SortedList list1 = new SortedList(); list1.Add("One", 1); list1.Add("Two ", 2); list1.Add("Three ", 3); list1.Add("Four", 4); list1.Add("Five", 5); list1.Add("Six", 6); list1.Add("Seven ", 7); list1.Add("Eight ", 8); list1.Add("Nine", 9); list1.Add("Ten", 10); Console.WriteLine("SortedList1 元素..."); foreach(DictionaryEntry ... 阅读更多
78 次浏览
要检查两个 OrderedDictionary 对象是否相等,代码如下所示:示例 在线演示using System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main() { OrderedDictionary dict1 = new OrderedDictionary(); dict1.Add("A", "Books"); dict1.Add("B", "Electronics"); dict1.Add("C", "Smart Wearables"); dict1.Add("D", "Pet Supplies"); dict1.Add("E", "Clothing"); dict1.Add("F", "Footwear"); Console.WriteLine("OrderedDictionary1 元素..."); foreach(DictionaryEntry d in dict1) { Console.WriteLine(d.Key + " " + d.Value); } ... 阅读更多
184 次浏览
从SortedList中移除指定键的元素,代码如下所示:示例 在线演示using System; using System.Collections; public class Demo { public static void Main(String[] args) { SortedList sortedList = new SortedList(); sortedList.Add("A", "1"); sortedList.Add("B", "2"); sortedList.Add("C", "3"); sortedList.Add("D", "4"); sortedList.Add("E", "5"); sortedList.Add("F", "6"); sortedList.Add("G", "7"); sortedList.Add("H", "8"); sortedList.Add("I", "9"); sortedList.Add("J", "10"); Console.WriteLine("SortedList 元素..."); foreach(DictionaryEntry d ... 阅读更多
浏览量:102
从ArrayList中移除指定索引处的元素,代码如下所示:示例 在线演示using System; using System.Collections; public class Demo { public static void Main(String[] args) { ArrayList list1 = new ArrayList(); list1.Add("A"); list1.Add("B"); list1.Add("C"); list1.Add("D"); list1.Add("E"); list1.Add("F"); list1.Add("G"); list1.Add("H"); list1.Add("I"); Console.WriteLine("ArrayList1 中的元素..."); foreach (string res in list1) { Console.WriteLine(res); } ... 阅读更多