This documentation is archived and is not being maintained.

ArrayList.Contains Method

Determines whether an element is in the ArrayList.

[Visual Basic]
Public Overridable Function Contains( _
   ByVal item As Object _
) As Boolean Implements IList.Contains
public virtual bool Contains(
 object item
public: virtual bool Contains(
 Object* item
public function Contains(
   item : Object
) : Boolean;


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.




This method performs a linear search; therefore, the average execution time is proportional to Count. That is, this method is an O(n) operation, where n is Count.

This method determines equality by calling Object.Equals.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

ArrayList Class | ArrayList Members | System.Collections Namespace | IndexOf | LastIndexOf | Performing Culture-Insensitive String Operations in Collections