Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

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
[C#]
public virtual bool Contains(
 object item
);
[C++]
public: virtual bool Contains(
 Object* item
);
[JScript]
public function Contains(
   item : Object
) : Boolean;

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.

Implements

IList.Contains

Remarks

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.

Requirements

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

Show:
© 2015 Microsoft