Share via


Contract.Exists 方法

定義

多載

Exists(Int32, Int32, Predicate<Int32>)

判斷整數範圍內是否有任何整數使指定的測試成立。

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

判斷項目集合內的項目是否出現在函式中。

Exists(Int32, Int32, Predicate<Int32>)

來源:
Contracts.cs
來源:
Contracts.cs
來源:
Contracts.cs

判斷整數範圍內是否有任何整數使指定的測試成立。

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

參數

fromInclusive
Int32

要傳遞至 predicate 的第一個整數。

toExclusive
Int32

要傳遞至 predicate 的最後一個整數加一。

predicate
Predicate<Int32>

要評估指定範圍內任何整數值的函式。

傳回

如果 predicate 為從 fromInclusive 開始到 toExclusive - 1 的任何整數傳回 true,則為 true

例外狀況

predicatenull

toExclusive 小於 fromInclusive

備註

參數 toExclusive 是最後一個以上的整數,可協助使用從 0 開始的整數範圍長度。 例如,整數 0 到 4 會將它設定為 5。

適用於

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

來源:
Contracts.cs
來源:
Contracts.cs
來源:
Contracts.cs

判斷項目集合內的項目是否出現在函式中。

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

類型參數

T

包含在 collection 中的型別。

參數

collection
IEnumerable<T>

要從中繪製型 T 別專案的集合,以傳遞至 predicate

predicate
Predicate<T>

要評估 collection 中項目的函式。

傳回

只有在 predicateT 中任何 collection 型別之項目傳回 true 時,才為 true

例外狀況

collectionpredicatenull

另請參閱

適用於