Freigeben über


List<T>.RemoveAll Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Removes all the elements that match the conditions defined by the specified predicate.

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

Syntax

'Declaration
Public Function RemoveAll ( _
    match As Predicate(Of T) _
) As Integer
public int RemoveAll(
    Predicate<T> match
)

Parameters

Return Value

Type: System.Int32
The number of elements removed from the List<T> .

Exceptions

Exception Condition
ArgumentNullException

match is nulla null reference (Nothing in Visual Basic).

Remarks

The Predicate<T> is a delegate to a method that returns true if the object passed to it matches the conditions defined in the delegate. The elements of the current List<T> are individually passed to the Predicate<T> delegate, and the elements that match the conditions are removed from the List<T>.

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

Version Information

Silverlight

Supported in: 5

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.