October 2017
Intermediate to advanced
440 pages
11h 47m
English
An array may be given a type in similar manner to a variable holding a single value. The difference is that the type name is followed by [] as was the case when creating an empty array of a specific size. For example, each of these is an array type, which may appear before a variable name:
[String[]] # An array of strings [UInt64[]] # An array of unsigned 64-bit integers [Xml[]] # An array of XML documents
If a type is set for the array, more care must be taken about assigning values. If a type is declared, PowerShell will attempt to convert any value assigned to an array element to that type.
In this example, $null will become 0, and 3.45 (a Double) will become 3 (normal rounding rules apply when converting integers): ...
Read now
Unlock full access