【Unity笔记】常见集合类System.Collections


ArrayList:长度可变数组,不限定类型

ArrayList al = new ArrayList();

List:替代ArrayList,限定类型

List list = new List<int>();

 


Hashtable:哈希表,不限定类型

Hashtable ht = new Hashtable();


Dictionary:替代Hashtable,限定类型

Dictionary<string, string> d = new Dictionary<string, string>();

 

SortedList:可排序的列表

SortedList<int, int> sl = new SortedList<int, int>();  
sl.Add(5, 105);  
sl.add(2, 102);  
sl.Add(10, 99);  
foreach(var v in sl){  
    Cosole.WriteLine(v.Value);  
}  
// 最终排序:key值会从小到大排序

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM