找到 34423 篇文章 关于编程
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 ... 阅读更多
103 次浏览
要从 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); } ... 阅读更多
53 次浏览
要获取 StringCollection 中字符串的数量,代码如下所示:示例 实时演示using System; using System.Collections.Specialized; public class Demo { public static void Main() { StringCollection strCol = new StringCollection(); String[] strArr = new String[] { "A", "B", "C", "D", "E", "F", "G", "H" }; Console.WriteLine("StringCollection 元素..."); foreach (string str in strArr) { Console.WriteLine(str); } strCol.AddRange(strArr); Console.WriteLine("第 5 个索引处的元素 = "+strCol[5]); Console.WriteLine("StringCollection 中字符串的数量 = " ... 阅读更多
66 次浏览
要获取或设置与 StringDictionary 中指定键关联的值,代码如下所示:示例 实时演示using System; using System.Collections.Specialized; public class Demo { public static void Main() { StringDictionary strDict = new StringDictionary (); strDict.Add("A", "Books"); strDict.Add("B", "Electronics"); strDict.Add("C", "Appliances"); strDict.Add("D", "Pet Supplies"); strDict.Add("E", "Clothing"); strDict.Add("F", "Footwear"); Console.WriteLine("与键 D 关联的值 = "+strDict["D"]); Console.WriteLine("与键 F 关联的值 = "+strDict["F"]); } }输出这将产生以下输出 ... 阅读更多
88 次浏览
要从 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("元素总数 = "+stringCol.Count); stringCol.RemoveAt(3); Console.WriteLine("元素总数 ... 阅读更多
64 次浏览
要获取元组的第七个元素,代码如下所示:示例 实时演示using System; public class Demo { public static void Main(String[] args) { var tuple1 = Tuple.Create(75, 200, 500, 700, 100, 1200, 1500); var tuple2 = Tuple.Create(75, 200, 500, 700, 100, 1200, 1500); Console.WriteLine("Tuple1 是否等于 Tuple2?= "+tuple1.Equals(tuple2)); Console.WriteLine("Tuple1 的哈希码 = "+tuple1.GetHashCode()); Console.WriteLine("Tuple2 的哈希码 = "+tuple2.GetHashCode()); Console.WriteLine("Tuple1 第 1 个项目 = "+tuple1.Item1); Console.WriteLine("Tuple2 第 1 个项目 = "+tuple2.Item1); Console.WriteLine("Tuple1 第 2 个项目 ... 阅读更多
150 次浏览
要从 Hashtable 中移除所有元素,代码如下所示:示例 实时演示using System; using System.Collections; public class Demo { public static void Main() { Hashtable hash = new Hashtable(10); hash.Add("1", "A"); hash.Add("2", "B"); hash.Add("3", "C"); hash.Add("4", "D"); hash.Add("5", "E"); hash.Add("6", "F"); hash.Add("7", "G"); hash.Add("8", "H"); hash.Add("9", "I"); hash.Add("10", "J"); Console.WriteLine("Hashtable 键值对..."); foreach(DictionaryEntry entry in hash) ... 阅读更多
331 次浏览
要从集合中移除所有元素,代码如下所示:示例 实时演示using System; using System.Collections.ObjectModel; public class Demo { public static void Main() { Collection col = new Collection(); col.Add(10); col.Add(20); col.Add(30); col.Add(40); col.Add(50); col.Add(60); col.Add(70); col.Add(80); Console.WriteLine("集合中的元素..."); foreach(int val in col) { Console.WriteLine(val); } Console.WriteLine("集合是否包含元素 ... 阅读更多
212 次浏览
要检查指定的 Unicode 字符是否为标点符号,代码如下所示:示例 实时演示using System; public class Demo { public static void Main() { bool res; char val = 'q'; Console.WriteLine("值 = "+val); res = Char.IsPunctuation(val); Console.WriteLine("该值是否为标点符号?= "+res); } }输出这将产生以下输出:值 = q 该值是否为标点符号?= False示例让我们看另一个示例: 实时演示using System; public class Demo { public static void Main() { ... 阅读更多
107 次浏览
要获取当前 Int64 实例的哈希码,代码如下:示例 在线演示使用 System;public class Demo { public static void Main() { long val1 = 8768768768; long val2 = 7889765555; Console.WriteLine("Value1 = "+val1); Console.WriteLine("Value2 = "+val2); Console.WriteLine("Are they equal? = "+val1.Equals(val2)); Console.WriteLine("Value1 (HashCode) = "+val1.GetHashCode()); Console.WriteLine("Value2 (HashCode) = "+val2.GetHashCode()); } }输出这将产生以下输出:Value1 = 8768768768 Value2 = 7889765555 Are they equal? = False Value1 (HashCode) = 178834178 Value2 (HashCode) = -700169038示例让我们看另一个例子: 在线演示使用 System;public class Demo { ... 阅读更多
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 语言编程
C++
C#
MongoDB
MySQL
Javascript
PHP