Enumerable.First<TSource> Method (IEnumerable<TSource>, Func<TSource, Boolean>)
Returns the first element in a sequence that satisfies a specified condition.
Assembly: System.Core (in System.Core.dll)
public static TSource First<TSource>( this IEnumerable<TSource> source, Func<TSource, bool> predicate )
The type of the elements of source.
The first element in the sequence that passes the test in the specified predicate function.
Usage NoteIn Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable<>. When you use instance method syntax to call this method, omit the first parameter.
The method throws an exception if no matching element is found in source. To instead return a default value when no matching element is found, use the FirstOrDefault method.
The following code example demonstrates how to use to return the first element of an array that satisfies a condition.
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.