ArrayList.Contains Method (System.Collections)

Switch View :
ScriptFree
ArrayList.Contains Method
Determines whether an element is in the ArrayList.

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

Syntax

Visual Basic (Declaration)
Public Overridable Function Contains ( _
	item As Object _
) As Boolean
Visual Basic (Usage)
Dim instance As ArrayList
Dim item As Object
Dim returnValue As Boolean

returnValue = instance.Contains(item)
C#
public virtual bool Contains (
	Object item
)
C++
public:
virtual bool Contains (
	Object^ item
)
J#
public boolean Contains (
	Object item
)
JScript
public function Contains (
	item : Object
) : boolean
XAML
Not applicable.

Parameters

item

The Object to locate in the ArrayList. The value can be a null reference (Nothing in Visual Basic).

Return Value

true if item is found in the ArrayList; otherwise, false.
Remarks

This method performs a linear search; therefore, this method is an O(n) operation, where n is Count.

This method determines equality by calling Object.Equals.

Starting with the .NET Framework 2.0, this method uses the collection’s objects’ Equals and CompareTo methods on item to determine whether item exists. In the earlier versions of the .NET Framework, this determination was made by using the Equals and CompareTo methods of the item parameter on the objects in the collection.

Platforms

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.

Version Information

.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
See Also