找到 34423 篇文章 关于编程
111 次浏览
要检查两个 StringBuilder 对象是否相等,代码如下所示 -示例 实时演示使用 System; 使用 System.Text; 公共类演示 { 公共静态无效 Main(字符串[] args){ StringBuilder strBuilder1 = 新 StringBuilder("Tim"); StringBuilder strBuilder2 = 新 StringBuilder("Tom"); StringBuilder strBuilder3 = 新 StringBuilder(); strBuilder2 = strBuilder3; Console.WriteLine("StringBuilder3 是否等于 StringBuilder2? = "+strBuilder3.Equals(strBuilder2)); } }输出这将产生以下输出 -StringBuilder3 是否等于 StringBuilder2? = True示例让我们看另一个示例 - 实时演示使用 System; 使用 System.Text; 公共类演示 { 公共静态无效 ... 阅读更多
148 次浏览
要检查两个 String 对象是否具有相同的值,代码如下所示 -示例 实时演示使用 System; 公共类演示 { 公共静态无效 Main(字符串[] args){ 字符串 str1 = "John"; 字符串 str2 = "John"; Console.WriteLine("字符串 1 = "+str1); Console.WriteLine("字符串 2 = "+str2); Console.WriteLine("字符串 1 等于字符串 2:{0}", str1.Equals(str2)); } }输出这将产生以下输出 -字符串 1 = John 字符串 2 = John 字符串 1 等于字符串 2:True示例让我们看另一个示例 - 实时演示使用 System; 公共 ... 阅读更多
138 次浏览
要为 ArrayList 创建只读包装器,代码如下所示 -示例 实时演示使用 System; 使用 System.Collections; 公共类演示 { 公共静态无效 Main(){ ArrayList 列表 = 新 ArrayList(); list.Add("One"); list.Add("Two"); list.Add("Three"); list.Add("Four"); list.Add("Five"); list.Add("Six"); list.Add("Seven"); list.Add("Eight"); Console.WriteLine("ArrayList 元素..."); 针对每个(字符串 str 在列表中){ Console.WriteLine(str); } Console.WriteLine("ArrayList 是否为只读? = "+list.IsReadOnly); } }输出这将产生 ... 阅读更多
304 次浏览
要获取一个迭代 SortedList 的枚举器,代码如下所示 -示例 实时演示使用 System; 使用 System.Collections; 公共类演示 { 公共静态无效 Main(字符串[] args){ SortedList sortedList = 新 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 元素..."); 针对每个(DictionaryEntry d 在 sortedList 中){ ... 阅读更多
61 次浏览
要使用指定的初始大小创建 HybridDictionary,代码如下所示 -示例 实时演示使用 System; 使用 System.Collections; 使用 System.Collections.Specialized; 公共类演示 { 公共静态无效 Main(){ HybridDictionary dict = 新 HybridDictionary(5); dict.Add("A", "AB"); dict.Add("B", "BC"); dict.Add("C", "DE"); dict.Add("D", "FG"); dict.Add("E", "HI"); Console.WriteLine("键/值对..."); 针对每个(DictionaryEntry d 在 dict 中) Console.WriteLine("键 = "+d.Key + ", 值 = " + d.Value); } }输出这将产生以下输出 -键/值对... 键 = A, ... 阅读更多
71 次浏览
要使用指定的初始大小创建区分大小写的 HybridDictionary,代码如下所示 -示例 实时演示使用 System; 使用 System.Collections; 使用 System.Collections.Specialized; 公共类演示 { 公共静态无效 Main(){ HybridDictionary myDict = 新 HybridDictionary(5, false); myDict.Add("A", "AB"); myDict.Add("B", "BC"); myDict.Add("C", "DE"); myDict.Add("D", "FG"); myDict.Add("e", "fg"); Console.WriteLine("键/值对..."); 针对每个(DictionaryEntry de 在 myDict 中) Console.WriteLine("键 = "+de.Key + ", 值 = " + de.Value); } }输出这将产生以下输出 -键/值对... 键 ... 阅读更多
122 次浏览
要从另一个集合创建 HashSet,代码如下所示 -示例 实时演示使用 System; 使用 System.Collections.Generic; 公共类演示 { 公共静态无效 Main(){ HashSet set1 = 新 HashSet(); set1.Add(100); set1.Add(200); set1.Add(300); Console.WriteLine("从另一个集合创建的 HashSet..."); 针对每个(int i 在 set1 中){ Console.WriteLine(i); } HashSet set2 = 新 HashSet(set1); Console.WriteLine("从另一个集合创建的 HashSet..."); 针对每个(int i 在 set2 中){ Console.WriteLine(i); } ... 阅读更多
83 次浏览
要从集合创建 Stack,代码如下所示 -示例 实时演示使用 System; 使用 System.Collections.Generic; 公共类演示 { 公共静态无效 Main(){ Stack 堆栈 = 新 Stack(); stack.Push(100); stack.Push(200); stack.Push(300); stack.Push(400); stack.Push(500); stack.Push(600); stack.Push(700); stack.Push(800); stack.Push(900); stack.Push(1000); Console.WriteLine("堆栈元素..."); 针对每个(int val 在堆栈中){ Console.WriteLine(val); } Console.WriteLine("数组元素..."); ... 阅读更多
79 次浏览
要检查两个 LinkedList 对象是否相等,代码如下所示 -示例 实时演示使用 System; 使用 System.Collections.Generic; 公共类演示 { 公共静态无效 Main(字符串[] args){ LinkedList list1 = 新 LinkedList(); list1.AddLast("One"); list1.AddLast("Two"); list1.AddLast("Three"); list1.AddLast("Four"); list1.AddLast("Five"); Console.WriteLine("LinkedList1 中的元素..."); 针对每个(字符串 res 在 list1 中){ Console.WriteLine(res); } LinkedList list2 = 新 LinkedList(); list2.AddLast("India"); list2.AddLast("US"); list2.AddLast("UK"); ... 阅读更多
703 次浏览
要删除列表中所有满足谓词定义的条件的元素,代码如下所示 -示例 实时演示使用 System; 使用 System.Collections.Generic; 公共类演示 { 私有静态布尔演示(int i){ 返回(i == 500); } 公共静态无效 Main(字符串[] args){ 列表列表 = 新列表(); list.Add(100); list.Add(500); list.Add(300); list.Add(400); list.Add(500); list.Add(600); list.Add(500); Console.WriteLine("列表元素..."); 针对每个(int i 在列表中){ ... 阅读更多
数据结构
网络
关系数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 语言编程
C++
C#
MongoDB
MySQL
Javascript
PHP