Hashtable.Contains 包含

function Contains (key : object) : bool

Description描述

Determines whether the Hashtable contains a specific key.

确定哈希表中是否包含一个指定的键。

This method implements IDictionary.Contains. It behaves exactly as ContainsKey. This method is an O(1) operation.

这个方法实现IDictionary.Contains方法(确定 IDictionary 对象是否包含具有指定键的元素)。它的行为和ContainsKey一样。这个方法是O(1)操作。

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");
		h.Add(3, "two");
		if (h.Contains(1))
			Debug.Log("Key '1', has been found!");

	}
}
// Searchs for a value on the hash table
//在哈希表上搜索一个值

var h : Hashtable;
h = new Hashtable();
h.Add(1,"one");
h.Add(2,"two");
h.Add(3,"two");
if(h.Contains(1)) {
	Debug.Log("Key '1', has been found!");
}
Page last updated: 2011-3-10