ToArray
Convert the Option<T>
to a T[]
of length 0 or 1.
Parameters
Returns
Option<T> option
T [ ]
Usage
Returns an T[]
with a single element when the option value IsSome
. Otherwise returns an empty collection.
When option IsSome
Option<int> optionValue = 42;
int[] result = optionValue.ToArray();
//result = [| 42 |]
When option IsNone
Option<int> optionValue = Option<int>.None();
int[] result = optionValue.ToArray();
//result = [||]
Last updated
Was this helpful?