【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值会从小到大排序
时间: 2024-08-10 00:04:09

【Unity笔记】常见集合类System.Collections的相关文章

C#中的常见集合类的比较

一.非泛型集合与泛型集合 非泛型集合:Array.ArrayList.HashTable.Queue.Statck.SortedList 泛型集合:List.Dictionary.Queue.Stack.SortedList 二.常见的集合类 Array.ArrayList.List (一)Array: 即常见的数组形式,大小固定,命名空间为System (二)ArrayList: 命名空间为System.Collection,是数组的复杂版本.ArrayList 类提供在大多数 Collect

(转)Unity笔记之编辑器(UnityEditor)

在使用unity3d的过程中,时常会需要从场景中寻找或者调用一个对象,而Unity就提供了一个贴心的功能——拖拽.用鼠标拖一下中比写堆代码直观的多吧!但是Unity提供的远远不止这一丢丢,下面我们来简单了解下UnityEditor部分的内容. 编辑器最最基本的用法呢就是编辑Inspector. 而Inspector中最最基本的就是把字段显示出来.给几个例子: [code]csharpcode: using UnityEngine; using System.Collections; // 这里没

[NHibernate]集合类(Collections)映射

系列文章 [Nhibernate]体系结构 [NHibernate]ISessionFactory配置 [NHibernate]持久化类(Persistent Classes) [NHibernate]O/R Mapping基础 引言 这部分不包括大量的.NET代码例子.我们假定你已经了解如何使用.NET自身的集合类框架(.NET's collections framework)和Set集合的概念.其实如果是这样,这里就真的没有什么东西需要学习了....用一句话来做个总结,你就用你已经掌握的知识

关于System.Collections空间

System.Collections命名空间包含可使用的集合类和相关的接口,提供了集合的基本功能. 该命名空间下的.NET非泛型集合类如下所示: — System.Collections.ArrayList:数组集合类,使用大小可按动态增加的数组实现Ilist接口.— System.Collections.BitArray:布尔集合类,管理位值的压缩数组,该值为布尔值.— System.Collections.Queue:队列,表示对象的先进先出集合.— System.Collections.S

System.Collections.Generic.List&lt;T&gt; 与 System.Collections.ArrayList

[推荐] System.Collections.Generic.List<T> [原因] 泛型集合类List<T>在操作值类型的集合时可以不进行 装箱/拆箱 处理. 使得性能较 ArrayList提高了相当大的程度.因为托管堆中需要创建的对象次数减少了,所以需要应用程序执行的垃圾回收次数也相应减少.除此之外,开发人员还获得了编译时的类型安全性,源代码也因为强制类型转换的次数减少而变得更清晰.

[Unity 笔记] unity中如何将Object序列化成xml字符串并保存

需要使用到以下这几个c#内置的命名空间. using System.Xml; using System.IO; using System.Xml.Serialization; 序列化并存储xml文件 XmlTextWriter xWrite = new XmlTextWriter(filename, null); XmlSerializer sl = new XmlSerializer(type); sl.Serialize(xWrite, target); xWrite.Close(); 读取

【Unity笔记】使用协程(Coroutine)异步加载场景

using UnityEngine; using System.Collections; using UnityEngine.SceneManagement; using System; public class LoadingPage : MonoBehaviour { public UISlider progressBar; // 目标进度 float target = 0; // 读取场景的进度,取值范围0~1 float progress = 0; // 异步对象 AsyncOperat

vs2013c#测试using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1_CXY { class Program { stati

首先安装Unit Test Generator.方法为:工具->扩展和更新->联机->搜索“图标为装有蓝色液体的小试管.Unit Test Generator”, 编写代码,生成一个新的类,编写构造函数 与 add()函数.代码如下. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Co

(转)Unity笔记之编辑器(CurveField、DoubleField、EnumMaskField、EnumPopup) ... ...

1. CurveField创建的是一个类型为AnimationCurve的曲线变量,看代码: [code]csharpcode: using UnityEngine; using System.Collections; using UnityEditor; // 编辑器命名空间的引用 public class Editor2 : EditorWindow // 编辑器类 { private AnimationCurve _animationCurve = new AnimationCurve()