Table of contents
TOC
Collapse the table of content
Expand the table of content

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

Den Delimarsky|Last Updated: 7/6/2016
|
1 Contributor

Creates an array from the given list.

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

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

Syntax

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

// Usage:
List.toArray list

Parameters

list Type: 'Tlist

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

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

Collections.List Module (F#)

Microsoft.FSharp.Collections Namespace (F#)

© 2017 Microsoft