 | CondensedCollectionExtensionsFirstOrDefaultTSource Method |
[This is preliminary documentation and is subject to change.]
Returns the first element of the sequence that satisfies a condition or a default value if
no such element is found. Optimized for a CondensedCollection.
Namespace:
Condensed.Linq
Assembly:
Condensed (in Condensed.dll) Version: 0.1.0.0 (0.1.0.0)
Syntaxpublic static TSource FirstOrDefault<TSource>(
this CondensedCollection<TSource> source,
Func<TSource, bool> predicate
)
<ExtensionAttribute>
Public Shared Function FirstOrDefault(Of TSource) (
source As CondensedCollection(Of TSource),
predicate As Func(Of TSource, Boolean)
) As TSource
public:
[ExtensionAttribute]
generic<typename TSource>
static TSource FirstOrDefault(
CondensedCollection<TSource>^ source,
Func<TSource, bool>^ predicate
)
[<ExtensionAttribute>]
static member FirstOrDefault :
source : CondensedCollection<'TSource> *
predicate : Func<'TSource, bool> -> 'TSource
Parameters
- source
- Type: CondensedCondensedCollectionTSource
The collection to return an element from. - predicate
- Type: SystemFuncTSource, Boolean
A function to test each element for a condition.
Type Parameters
- TSource
- The type of the elements of source.
Return Value
Type:
TSource
default(T) if source is empty or if no element passes the test specified by predicate;
otherwise, the first element in source that passes the test specified by predicate.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
CondensedCollectionTSource. 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).
Remarks
This implementation of FirstOrDefault() is specialized for a CondensedCollection and tries to
take advantage of the CondensedCollection's knowledge of unique values in order to improve performance.
If you would rather use the normal LINQ extension method then cast the CondensedCollection to an
IListT
to use the
FirstOrDefaultTSource(IEnumerableTSource, FuncTSource, Boolean) implementation.
See Also