OptionExtensionsLinqFirstOrNoneT(IEnumerableT, FuncT, Boolean) Method

Returns Some of the first element of the collection satisfying the filter if any; None otherwise.
C#
Assert(Array.Empty<int>().FirstOrNone(x => x > 2).IsNone);
Assert((new int[2] { 1, 2 }).FirstOrNone(x => x > 2).IsNone);
Assert((new int[2] { 1, 2 }).FirstOrNone(x => x > 1) == Some(2));

Definition

Namespace: Orx.Fun.Option
Assembly: Orx.Fun.Option (in Orx.Fun.Option.dll) Version: 1.2.1+ea79806fa5e0e04bfdaef2a1916930e75e2cde74
C#
public static Opt<T> FirstOrNone<T>(
	this IEnumerable<T> collection,
	Func<T, bool> filter
)

Parameters

collection  IEnumerableT
Collection.
filter  FuncT, Boolean
Predicate to filter the items of the collection.

Type Parameters

T

[Missing <typeparam name="T"/> documentation for "M:Orx.Fun.Option.OptionExtensionsLinq.FirstOrNone``1(System.Collections.Generic.IEnumerable{``0},System.Func{``0,System.Boolean})"]

Return Value

OptT

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerableT. 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