Version: 2017.3

描述

将计数设置为零,并释放集合元素中对其他对象的引用。

容量保持不变。 /此方法是 O(n) 操作,其中 n 为 Hashtable.Count。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Hashtable h; void Example() { h = new Hashtable(); h.Add("1", "one"); h.Add("2", "two"); Debug.Log(h.Count); h.Clear(); Debug.Log(h.Count); } }