Contract.ForAll Method (Int32, Int32, Predicate<Int32>)
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Determines whether a particular condition is valid for all integers in a specified range.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- fromInclusive
- Type: System.Int32
The first integer to pass to predicate.
- toExclusive
- Type: System.Int32
One more than the last integer to pass to predicate.
- predicate
- Type: System.Predicate<Int32>
The function to evaluate for the existence of the integers in the specified range.
Return Value
Type: System.Booleantrue if predicate returns true for all integers starting from fromInclusive to toExclusive - 1.
| Exception | Condition |
|---|---|
| ArgumentNullException | predicate is null. |
| ArgumentException | toExclusive is less than fromInclusive. |
The following example demonstrates how to use the ForAll method to determine whether an array has a null element.
Show: