Hashtable.KeyEquals Method

Compares a specific Object with a specific key in the Hashtable.

Namespace: System.Collections
Assembly: mscorlib (in mscorlib.dll)

protected virtual bool KeyEquals (
	Object item,
	Object key
protected boolean KeyEquals (
	Object item, 
	Object key
protected function KeyEquals (
	item : Object, 
	key : Object
) : boolean
Not applicable.



The Object to compare with key.


The key in the Hashtable to compare with item.

Return Value

true if item and key are equal; otherwise, false.

Exception typeCondition


item is a null reference (Nothing in Visual Basic).


key is a null reference (Nothing in Visual Basic).

If the hash table was created with a specific IComparer implementation, this method uses that comparer; that is, Compare (item, key). Otherwise, it uses item.Equals(key).

This method is an O(1) operation.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0

Community Additions