Share via


Contains Method

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Determines whether the Hashtable contains a specific key.

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

Syntax

'Declaration
Public Function Contains ( _
    key As Object _
) As Boolean
public bool Contains(
    Object key
)
public:
virtual bool Contains(
    Object^ key
) sealed
abstract Contains : 
        key:Object -> bool 
override Contains : 
        key:Object -> bool 
public final function Contains(
    key : Object
) : boolean

Parameters

Return Value

Type: System. . :: . .Boolean
true if the Hashtable contains an element with the specified key; otherwise, false.

Implements

IDictionary. . :: . .Contains(Object)

Exceptions

Exception Condition
ArgumentNullException

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

Remarks

Contains implements IDictionary..::..Contains. It behaves exactly as ContainsKey.

This method is an O(1) operation.

.NET Framework Security

See Also

Reference

Hashtable Class

System.Collections Namespace