OptionExtensionsLinqGetT(T, Int32) Method

Returns Some of the element at the given index of the array if it is a valid index; None otherwise.
C#
Assert(Array.Empty<Title>().Get(1).IsNone);
Assert((new int[2] { 1, 2 }).Get(2) == Some(1));
Assert((new int[2] { 1, 2 }).Get(0) == Some(1));

Definition

Namespace: Orx.Fun.Option
Assembly: Orx.Fun.Option (in Orx.Fun.Option.dll) Version: 1.2.1+ea79806fa5e0e04bfdaef2a1916930e75e2cde74
C#
public static Opt<T> Get<T>(
	this T[] array,
	int index
)

Parameters

array  T
Array.
index  Int32
Index of the element to return.

Type Parameters

T

[Missing <typeparam name="T"/> documentation for "M:Orx.Fun.Option.OptionExtensionsLinq.Get``1(``0[],System.Int32)"]

Return Value

OptT

Usage Note

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