Array.create<'T> Function
Collapse the table of content
Expand the table of content

Array.create<'T> Function (F#)

Creates an array whose elements are all initially the given value.

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

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

// Signature:
Array.create : int -> 'T -> 'T []

// Usage:
Array.create count value


Type: int

The length of the array to create.


Type: 'T

The value for the elements.

The created array.

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

The following code illustrates the use of Array.create as well as setting and getting array values.

let array1 = Array.create 10 "" 
for i in 0 .. array1.Length - 1 do
    Array.set array1 i (i.ToString())
for i in 0 .. array1.Length - 1 do
    printf "%s " (Array.get array1 i)
0 1 2 3 4 5 6 7 8 9

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

F# Core Library Versions

Supported in: 2.0, 4.0, Portable

© 2015 Microsoft