Hashtable.KeyEquals(Object, Object) 方法

定義

比較特定的 ObjectHashtable 中的特定索引鍵。Compares a specific Object with a specific key in the Hashtable.

protected:
 virtual bool KeyEquals(System::Object ^ item, System::Object ^ key);
protected virtual bool KeyEquals (object item, object key);
protected virtual bool KeyEquals (object? item, object key);
abstract member KeyEquals : obj * obj -> bool
override this.KeyEquals : obj * obj -> bool
Protected Overridable Function KeyEquals (item As Object, key As Object) As Boolean

參數

item
Object

要和 key 比較的 ObjectThe Object to compare with key.

key
Object

要和 item 比較的 Hashtable 索引鍵。The key in the Hashtable to compare with item.

傳回

Boolean

如果 itemkey 相等,則為 true;否則為 falsetrue if item and key are equal; otherwise, false.

例外狀況

itemnullitem is null.

-或--or- keynullkey is null.

備註

如果雜湊資料表是使用特定的實作為建立的 IComparer ,則這個方法會使用該比較子,也就是 Compare (itemkey) 。If the hash table was created with a specific IComparer implementation, this method uses that comparer; that is, Compare (item, key). 否則,它會使用 item.Equals(key)Otherwise, it uses item.Equals(key).

這個方法是一項作業 O(1)This method is an O(1) operation.

適用於

另請參閱