Поделиться через


Contract.Exists<T> Method (IEnumerable<T>, Predicate<T>)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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

Namespace:  System.Diagnostics.Contracts
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Shared Function Exists(Of T) ( _
    collection As IEnumerable(Of T), _
    predicate As Predicate(Of T) _
) As Boolean
public static bool Exists<T>(
    IEnumerable<T> collection,
    Predicate<T> predicate
)

Type Parameters

  • T
    The type that is contained in collection.

Parameters

  • predicate
    Type: System.Predicate<T>
    The function to evaluate for an element in collection.

Return Value

Type: System.Boolean
true if and only if predicate returns true for any element of type T in collection.

Exceptions

Exception Condition
ArgumentNullException

collection or predicate is nulla null reference (Nothing in Visual Basic).

Version Information

Silverlight

Supported in: 5, 4

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.