February 2019
Intermediate to advanced
626 pages
15h 51m
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 as regards assigning values. If a type is declared, PowerShell will attempt to convert any value assigned to an array element into 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