Click or drag to resize
AlgorithmsFindFirstWhereT Method
Finds the first item in a collection that satisfies the condition defined by predicate.

Namespace: X3Platform.Collections
Assembly: X3Platform.Support (in X3Platform.Support.dll) Version: 1.0.0.0 (2.0.0.0)
Syntax
public static T FindFirstWhere<T>(
	IEnumerable<T> collection,
	Predicate<T> predicate
)

Parameters

collection
Type: System.Collections.GenericIEnumerableT
The collection to search.
predicate
Type: SystemPredicateT
A delegate that defined the condition to check for.

Type Parameters

T

[Missing <typeparam name="T"/> documentation for "M:X3Platform.Collections.Algorithms.FindFirstWhere``1(System.Collections.Generic.IEnumerable{``0},System.Predicate{``0})"]

Return Value

Type: T
The first item in the collection that matches the condition, or the default value for T (0 or null) if no item that matches the condition is found.
Remarks
If the default value for T could be present in the collection, and would be matched by the predicate, then this method is inappropriate, because you cannot disguish whether the default value for T was actually present in the collection, or no items matched the predicate. In this case, use TryFindFirstWhere.
See Also