C# 中的集合(Array/ArrayList/List<T>/HashTable/Dictionary)
C# 中的集合(Array/ArrayList/List<T>/HashTable/Dictionary)
int [] numbers = new int[5]; // 长度为5,元素类型为 int。 不同的格式:
names.GetLength(0); // 获得二维数组的横向长度 names.GetLength(1); // 获得二维数组的纵向长度。 |
|
System.Collections.ArrayList ArrayList al = new ArrayList(); al.Add(5); al.Add("Hello Tom"); |
System.Collections.Generic.List<T> List<int> intList = new List<int>(); intList.Add(500); intList.AddRange(new int[]{1,100}; intList.Insert(1, 1000); cw(intList.Contains(100)); cw(intList.indexOf(10)); |
System.Collections.HashTable HashTable ht = new HashTable(); ht.Add("name", "Tom"); ht.Add("age", 18); |
System.Collections.Generic.Dictionary<TKey, TValue> Dictionary<string, string> dic = new Dictionary<string, string>(); dic.Add("name", "Tom"); dic.Add("age", "eighteen"); |
哈 居然有人留言了。
简单说一下区别吧。
1、数组(Array)和 其余四个的区别是【类型指定】【长度固定】,其余四个长度都可以不固定(也可以指定长度)。
2、ArrayList 和 List<T> 的区别是 List<T> 是【类型指定】的。
3、HashTable 和 Dictionary<Tkey, Tvalue> 的 区别和 2 中的一样。后者是【类型指定】的。
分类: C#
- C# 中的集合(Array/ArrayList/List<T>/HashTable/Dictionary)
- C# 中的集合(Array/ArrayList/List<T>/HashTable/Dictionary)
- C#常见的几种集合 ArrayList,Hashtable,List<T>,Dictionary<K,V> 遍历方法对比
- C#使用集合组织数据(HashTable、ArrayList、List<T>,Dictionary<K,V>
- C#集合的區別(Array、Arraylist、 List、 Hashtable、SortedList、 Dictionary、 Stack、 Queue )
- [C#]泛型与非泛型集合类的区别及使用例程,包括ArrayList,Hashtable,List<T>,Dictionary<Tkey,Tvalue>,SortedList<Tkey,Tvalue>,Queue<T>,Stack<T>等
- C#集合类(Array、Arraylist、List、Hashtable、Dictionary、Stack、Queue)
- 总结C#集合类 Array Arraylist List Hashtable Dictionary
- C# 集合类总结(Array,Arraylist,List,Hashtable,Dictionary,Stack,Queue)
- .Net学习 第2季05 C#面向对象 ArrayList Hashtable List<> Dictionary<>
- C#集合类(Array、Arraylist、List、Hashtable、Dictionary、Stack、Queue)
- Array,ArrayList,List<>,Dictionary和HashTable
- [C#]泛型与非泛型集合类的区别及使用例程,包括ArrayList,Hashtable,List<T>,Dictionary<Tkey,Tvalue>,SortedList<Tkey,Tvalue>,
- 粗谈C#里 dictionary,HashTable,List<T>,Array 的性能优缺和实现原理。
- C#集合类(Array、Arraylist、List、Hashtable、Dictionary、Stack、Queue)
- C# 集合类总结 :(Array、 Arraylist、List、Hashtable、Dictionary、Stack、Queue)
- C# 数组集合 <一>基本概念(Array&ArrayList&List<T>&SortList&LinkList的实现Code)
- C# 集合类 Array Arraylist List Hashtable Dictionary Stack Queue
- C# 集合类 Array, Arraylist, List, Hashtable, Dictionary, Stack, Queue
- C# 集合类 Array Arraylist List Hashtable Dictionary Stack Queue