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.
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.Booleantrue if and only if predicate returns true for all elements of type T in collection.
| Exception | Condition |
|---|---|
| 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.
Show: