1.ArrayList类

C#  6种常用集合类using System;
C#  6种常用集合类
using System.Collections.Generic;
C#  6种常用集合类
using System.Text;
C#  6种常用集合类
using System.Collections;
C#  6种常用集合类
namespace ConsoleApplication1

C#  6种常用集合类

 

2.Stack类

栈,后进先出。push方法入栈,pop方法出栈。

 

C#  6种常用集合类using System;
C#  6种常用集合类
using System.Collections.Generic;
C#  6种常用集合类
using System.Text;
C#  6种常用集合类
using System.Collections;
C#  6种常用集合类
namespace ConsoleApplication1

C#  6种常用集合类

 

3.Queue类

队列,先进先出。enqueue方法入队列,dequeue方法出队列。

 

C#  6种常用集合类using System;
C#  6种常用集合类
using System.Collections.Generic;
C#  6种常用集合类
using System.Text;
C#  6种常用集合类
using System.Collections;
C#  6种常用集合类
namespace ConsoleApplication1

C#  6种常用集合类

 

4.Hashtable类

哈希表,名-值对。类似于字典(比数组更强大)。哈希表是经过优化的,访问下标的对象先散列过。如果以任意类型键值访问其中元素会快于其他集合。GetHashCode()方法返回一个int型数据,使用这个键的值生成该int型数据。哈希表获取这个值最后返回一个索引,表示带有给定散列的数据项在字典中存储的位置。

 

C#  6种常用集合类using System;
C#  6种常用集合类
using System.Collections.Generic;
C#  6种常用集合类
using System.Text;
C#  6种常用集合类
using System.Collections;
C#  6种常用集合类
namespace ConsoleApplication1

C#  6种常用集合类

 

5.SortedList类

与哈希表类似,区别在于SortedList中的Key数组排好序的。

 

C#  6种常用集合类using System;
C#  6种常用集合类
using System.Collections.Generic;
C#  6种常用集合类
using System.Text;
C#  6种常用集合类
using System.Collections;
C#  6种常用集合类
namespace ConsoleApplication1

C#  6种常用集合类

 

6.NameValueCollection类

官方给NameValueCollection定义为特殊集合一类,在System.Collections.Specialized下。

System.Collections.Specialized下还有HybridDicionary类,建议少于10个元素用HybridDicionary,当元素增加会自动转为HashTable。

System.Collections.Specialized下还有HybridDicionary类,字符串集合。

System.Collections.Specialized下还有其他类大家可以各取所需!

言归正转主要说NameValueCollection,HashTable 和 NameValueCollection很类似但是他们还是有区别的,HashTable 的KEY是唯一性,而NameValueCollection则不唯一

 

C#  6种常用集合类using System;
C#  6种常用集合类
using System.Collections.Generic;
C#  6种常用集合类
using System.Collections;
C#  6种常用集合类
using System.Collections.Specialized;
C#  6种常用集合类
namespace ConsoleApplication1

C#  6种常用集合类

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-22
  • 2021-06-28
  • 2021-11-21
猜你喜欢
  • 2021-11-02
  • 2021-06-13
  • 2021-12-04
相关资源
相似解决方案