ForAll(T) Method (IEnumerable(T), Predicate(T))
Collapse the table of content
Expand the table of content

Contract.ForAll(Of T) Method (IEnumerable(Of T), Predicate(Of T))

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Determines whether all the elements in a collection exist within a function.

Namespace:  System.Diagnostics.Contracts
Assembly:  mscorlib (in mscorlib.dll)

'Declaration
Public Shared Function ForAll(Of T) ( _
	collection As IEnumerable(Of T), _
	predicate As Predicate(Of T) _
) As Boolean

Type Parameters

T

The type that is contained in collection.

Parameters

collection
Type: System.Collections.Generic.IEnumerable(Of T)
The collection from which elements of type T will be drawn to pass to predicate.
predicate
Type: System.Predicate(Of T)
The function to evaluate for the existence of all the elements in collection.

Return Value

Type: System.Boolean
true if and only if predicate returns true for all elements of type T in collection.

ExceptionCondition
ArgumentNullException

collection or predicate is Nothing.

The following example demonstrates how to use the ForAll method to determine whether a collection has a null element.

Windows Phone OS

Supported in: 8.1, 8.0

Show:
© 2017 Microsoft