語言

Contract.Exists 方法

定義

多載

名稱 Description
Exists(Int32, Int32, Predicate<Int32>)

判斷某特定檢定是否適用於整數範圍內的任何整數。

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

判斷元素集合中的元素是否存在於函數中。

Exists(Int32, Int32, Predicate<Int32>)

來源:
Contracts.cs
來源:
Contracts.cs
來源:
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>

用來評估指定範圍內任意整數值的函數。

傳回

true若predicate對任意整數從 true 到 fromInclusive - 1 回傳toExclusive。

例外狀況

predicate 是 null。

toExclusive 小於 fromInclusive。

備註

toExclusive參數比最後一個整數多一個,以便利用從0開始的整數範圍長度。 例如,整數 0 到 4 會設為 5。

另請參閱

適用於

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

來源:
Contracts.cs
來源:
Contracts.cs
來源:
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某元素。

傳回

true當且僅當 predicate 回傳 true 對 中任意型態Tcollection元素。

例外狀況

collection 或 predicate 為 null。

另請參閱

適用於