找到 34423 篇文章 关于编程
140 次浏览
要获取包含哈希表键的ICollection,代码如下:示例 在线演示 using System; using System.Collections; public class Demo { public static void Main() { Hashtable hash = new Hashtable(); hash.Add("A", "Electronics"); hash.Add("B", "Appliances"); hash.Add("C", "Pet Supplies"); hash.Add("D", "Books"); hash.Add("E", "Toys"); hash.Add("F", "Footwear"); hash.Add("G", "Clothing"); ICollection col = hash.Keys; foreach(string str in col) Console.WriteLine(str + ": " + hash[str]); } }输出这… 阅读更多
142 次浏览
要获取 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 length = "+arr1.Length); Console.WriteLine("BitArray1 first element = "+arr1.Get(0)); arr2[0] = false; arr2[1] = true; Console.WriteLine("BitArray2 length = "+arr2.Length); Console.WriteLine("Elements in BitArray2..."); ... 阅读更多
135 次浏览
要获取或设置与哈希表中指定键关联的值,代码如下:示例 在线演示 using System; using System.Collections; public class Demo { public static void Main() { Hashtable hash = new Hashtable(); hash.Add("1", "AB"); hash.Add("2", "BC"); hash.Add("3", "DE"); hash.Add("4", "EF"); hash.Add("5", "GH"); hash.Add("6", "IJ"); hash.Add("7", "KL"); hash.Add("8", "MN"); hash.Add("9", "OP"); hash.Add("10", "QR"); Console.WriteLine("Value at key 3 = "+hash["3"]); ... 阅读更多
57 次浏览
要获取或设置 ArrayList 可容纳的元素数量,代码如下:示例 在线演示 using System; using System.Collections; public class Demo { public static void Main() { ArrayList arrList = new ArrayList(); arrList.Add(25); arrList.Add(50); arrList.Add(75); arrList.Add(100); arrList.Add(125); arrList.Add(150); arrList.Add(175); arrList.Add(200); arrList.Add(225); arrList.Add(250); Console.WriteLine("Elements in ArrayList..."); foreach(int i in arrList) { Console.WriteLine(i); ... 阅读更多
75 次浏览
要获取 SortedList 对象的值列表,代码如下:示例 在线演示 using System; using System.Collections; public class Demo { public static void Main(String[] args) { SortedList list = new SortedList(); list.Add("A", 1); list.Add("B ", 2); list.Add("C ", 3); list.Add("D", 4); list.Add("E", 5); list.Add("F", 6); list.Add("G", 7); list.Add("H", 8); Console.WriteLine("SortedList elements..."); foreach(DictionaryEntry d in list) { Console.WriteLine(d.Key + ... 阅读更多
638 次浏览
要获取 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 elements..."); ... 阅读更多
69 次浏览
要获取或设置 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 length = "+arr1.Length); Console.WriteLine("Elements in BitArray1..."); foreach (bool res in arr1) { Console.WriteLine(res); } arr2[0] = false; arr2[1] ... 阅读更多
85 次浏览
要计算 SortedSet 与集合的并集,代码如下:示例 在线演示 using System; using System.Collections.Generic; public class Demo { public static void Main() { SortedSet set1 = new SortedSet(); set1.Add(50); set1.Add(100); set1.Add(150); Console.WriteLine("SortedSet1 elements..."); foreach(int ele in set1) { Console.WriteLine(ele); } SortedSet set2 = new SortedSet(); set2.Add(100); set2.Add(150); set2.Add(200); set2.Add(250); Console.WriteLine("SortedSet2 elements..."); ... 阅读更多
56 次浏览
让我们看看如何实现 BitArray 元素之间的按位或运算:示例 在线演示 using System; using System.Collections; public class Demo { public static void Main() { BitArray arr1 = new BitArray(5); BitArray arr2 = new BitArray(5); arr1[0] = false; arr1[1] = false; arr2[0] = false; arr2[1] = true; Console.WriteLine("BitArray1 elements..."); foreach (bool res in arr1) { Console.WriteLine(res); } Console.WriteLine("BitArray2 elements..."); ... 阅读更多
849 次浏览
要获取或设置ArrayList中指定索引处的元素,代码如下所示:示例 在线演示使用 System; using System.Collections; public class Demo { public static void Main() { ArrayList arrList = new ArrayList(); arrList.Add("Laptop"); arrList.Add("Desktop"); arrList.Add("Notebook"); arrList.Add("Ultrabook"); arrList.Add("Tablet"); arrList.Add("Headphone"); arrList.Add("Speaker"); Console.WriteLine("ArrayList中的元素..."); foreach(string str in arrList) { Console.WriteLine(str); } Console.WriteLine("索引5处的元素 = " ... 阅读更多
数据结构
网络
关系数据库管理系统 (RDBMS)
操作系统
Java
iOS
HTML
CSS
Android
Python
C语言编程
C++
C#
MongoDB
MySQL
Javascript
PHP