Skip to content

M_CodeJam_Collections_EnumerableExtensions_FirstOrDefault__1_1

andrewvk edited this page Mar 30, 2016 · 9 revisions

EnumerableExtensions.FirstOrDefault(T) Method (IEnumerable(T), T, Func(T, Boolean))

[This is preliminary documentation and is subject to change.]

Returns first element, or specified defaultValue, if sequence is empty.

Namespace: CodeJam.Collections
Assembly: CodeJam (in CodeJam.dll) Version: 1.0.0.0 (1.0.0.0)

Syntax

C#

[PureAttribute]
public static T FirstOrDefault<T>(
	[NotNullAttribute][InstantHandleAttribute] this IEnumerable<T> source,
	T defaultValue,
	[NotNullAttribute][InstantHandleAttribute] Func<T, bool> predicate
)

VB

<ExtensionAttribute>
<PureAttribute>
Public Shared Function FirstOrDefault(Of T) ( 
	<NotNullAttribute><InstantHandleAttribute> source As IEnumerable(Of T),
	defaultValue As T,
	<NotNullAttribute><InstantHandleAttribute> predicate As Func(Of T, Boolean)
) As T

F#

[<ExtensionAttribute>]
[<PureAttribute>]
static member FirstOrDefault : 
        [<NotNullAttribute>][<InstantHandleAttribute>] source : IEnumerable<'T> * 
        defaultValue : 'T * 
        [<NotNullAttribute>][<InstantHandleAttribute>] predicate : Func<'T, bool> -> 'T 

Parameters

 

source
Type: System.Collections.Generic.IEnumerable(T)
[Missing documentation for "M:CodeJam.Collections.EnumerableExtensions.FirstOrDefault1(System.Collections.Generic.IEnumerable{0},0,System.Func{0,System.Boolean})"]
defaultValue
Type: T
[Missing documentation for "M:CodeJam.Collections.EnumerableExtensions.FirstOrDefault1(System.Collections.Generic.IEnumerable{0},0,System.Func{0,System.Boolean})"]
predicate
Type: System.Func(T, Boolean)
[Missing documentation for "M:CodeJam.Collections.EnumerableExtensions.FirstOrDefault1(System.Collections.Generic.IEnumerable{0},0,System.Func{0,System.Boolean})"]

Type Parameters

 

T

Return Value

Type: T
[Missing documentation for "M:CodeJam.Collections.EnumerableExtensions.FirstOrDefault1(System.Collections.Generic.IEnumerable{0},0,System.Func{0,System.Boolean})"]

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable(T). When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

See Also

Reference

EnumerableExtensions Class
FirstOrDefault Overload
CodeJam.Collections Namespace

Clone this wiki locally