Here’s two more ways, both very concise.
$arr1 = @(0) * 20
$arr2 = ,0 * 20
More Related Contents:
- Not all properties displayed
- Select the values of one property on all objects of an array in PowerShell
- Comparing two arrays & get the values which are not common
- Objects with no ‘.Count’ Property – use of @() (array subexpression operator) vs. [Array] cast
- Get-ChildItem.Length is Wrong
- Array.Add vs +=
- How do I pass an array as a parameter to another script?
- Pipe complete array-objects instead of array items one at a time?
- PowerShell copy an array completely
- A cmdlet which returns multiple objects, what collection type is it, if any? [PowerShell]
- How to add hashtable to multidimensional array? Cannot assign values via member-access enumeration
- Data Rows to String to Array issue
- Create a Single-Element Json Array Object Using PowerShell
- Powershell: Piping output of pracl command to array
- Return Multidimensional Array From Function
- How do I call New-Object for a constructor which takes a single array parameter?
- Why is a leading comma required when creating an array?
- PowerShell doesn’t return an empty array as an array
- Getting “System.Collections.Generic.List`1[System.String]” in CSV File export when data is okay on screen
- How do I create array of arrays in PowerShell?
- remove an index number from array
- Element-wise array replication in Matlab
- What is the ideal growth rate for a dynamically allocated array?
- Two-dimensional array in Swift
- How to iterate over array of objects in Handlebars?
- 1D Number Array Clustering
- Swift 3 2d array of Int
- How is the array stored in memory?
- A data structure supporting O(1) random access and worst-case O(1) append?
- Is there any way to allocate a standard Rust array directly on the heap, skipping the stack entirely?