ערוך

שתף באמצעות


Contract.Exists Method

Definition

Overloads

Exists(Int32, Int32, Predicate<Int32>)

Determines whether a specified test is true for any integer within a range of integers.

Exists<T>(IEnumerable<T>, Predicate<T>)

Determines whether an element within a collection of elements exists within a function.

Exists(Int32, Int32, Predicate<Int32>)

Source:
Contracts.cs
Source:
Contracts.cs
Source:
Contracts.cs

Determines whether a specified test is true for any integer within a range of integers.

public:
 static bool Exists(int fromInclusive, int toExclusive, Predicate<int> ^ predicate);
public static bool Exists (int fromInclusive, int toExclusive, Predicate<int> predicate);
static member Exists : int * int * Predicate<int> -> bool
Public Shared Function Exists (fromInclusive As Integer, toExclusive As Integer, predicate As Predicate(Of Integer)) As Boolean

Parameters

fromInclusive
Int32

The first integer to pass to predicate.

toExclusive
Int32

One more than the last integer to pass to predicate.

predicate
Predicate<Int32>

The function to evaluate for any value of the integer in the specified range.

Returns

true if predicate returns true for any integer starting from fromInclusive to toExclusive - 1.

Exceptions

predicate is null.

toExclusive is less than fromInclusive.

Remarks

The toExclusive parameter is one more than the last integer to facilitate using the length of a range of integers starting at 0. For example, it would be set to 5 for integers 0 through 4.

See also

Applies to

Exists<T>(IEnumerable<T>, Predicate<T>)

Source:
Contracts.cs
Source:
Contracts.cs
Source:
Contracts.cs

Determines whether an element within a collection of elements exists within a function.

public:
generic <typename T>
 static bool Exists(System::Collections::Generic::IEnumerable<T> ^ collection, Predicate<T> ^ predicate);
public static bool Exists<T> (System.Collections.Generic.IEnumerable<T> collection, Predicate<T> predicate);
static member Exists : seq<'T> * Predicate<'T> -> bool
Public Shared Function Exists(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
IEnumerable<T>

The collection from which elements of type T will be drawn to pass to predicate.

predicate
Predicate<T>

The function to evaluate for an element in collection.

Returns

true if and only if predicate returns true for any element of type T in collection.

Exceptions

collection or predicate is null.

See also

Applies to