Freigeben über


List.toArray<'T> Function (F#)

Creates an array from the given list.

Namespace/Module Path: Microsoft.FSharp.Collections.List

Assembly: FSharp.Core (in FSharp.Core.dll)

// Signature:
List.toArray : 'T list -> 'T []

// Usage:
List.toArray list

Parameters

  • list
    Type: 'T list

    The input list.

Return Value

The array containing the elements of the list.

Remarks

This function is named ToArray in compiled assemblies. If you are accessing the function from a .NET language other than F#, or through reflection, use this name.

Example

The following code shows how to use List.toArray.

let array1 = [ 1; 3; -2; 4 ]
             |> List.toArray
Array.set array1 3 -10
Array.sortInPlaceWith (fun elem1 elem2 -> compare elem1 elem2) array1
printfn "%A" array1

Output

[|-10; -2; 1; 3|]

Platforms

Windows 8, Windows 7, Windows Server 2012, Windows Server 2008 R2

Version Information

F# Core Library Versions

Supported in: 2.0, 4.0, Portable

See Also

Reference

Collections.List Module (F#)

Microsoft.FSharp.Collections Namespace (F#)