Hashtable.Clear 清除

function Clear () : void

Description描述

Count is set to zero, and references to other objects from elements of the collection are also released.

数量被设置为0,并且从该集合中元素到其他对象的引用也将被释放。

The capacity remains unchanged. This method is an O(n) operation, where n is Hashtable.Count.

容量没有改变。这个方法是O(n)操作,这里n是Hashtable.Count

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public Hashtable h;
	public void Awake() {
		h = new Hashtable();
		h.Add("1", "one");
		h.Add("2", "two");
		Debug.Log(h.Count);
		h.Clear();
		Debug.Log(h.Count);
	}
}
// Creates a Hashtable, adds 2 elements and then clears it
//创建一个哈希表,添加2个元素,然后清除它

var h : Hashtable;
h = new Hashtable();
h.Add("1","one");
h.Add("2","two");
Debug.Log(h.Count);
h.Clear();
Debug.Log(h.Count);
Page last updated: 2011-3-10