-
Notifications
You must be signed in to change notification settings - Fork 35
M_CodeJam_Collections_EnumerableExtensions_FirstOrDefault__1
Andrew Koryavchenko edited this page Jun 17, 2018
·
9 revisions
Returns first element, or specified defaultValue, if sequence is empty.
Namespace: CodeJam.Collections
Assembly: CodeJam (in CodeJam.dll) Version: 2.1.0.0
C#
public static T FirstOrDefault<T>(
this IEnumerable<T> source,
T defaultValue
)
VB
<ExtensionAttribute>
Public Shared Function FirstOrDefault(Of T) (
source As IEnumerable(Of T),
defaultValue As T
) As T
F#
[<ExtensionAttribute>]
static member FirstOrDefault :
source : IEnumerable<'T> *
defaultValue : 'T -> 'T
- source
- Type: System.Collections.Generic.IEnumerable(T)
An IEnumerable(T) to return an element from. - defaultValue
- Type: T
Default value.
- T
- The type of the elements of source.
Type: Tdefault
(T) if source is empty; otherwise, the first element in source.
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).
EnumerableExtensions Class
FirstOrDefault Overload
CodeJam.Collections Namespace