In PowerShell, you can create a byte array, an array of legendary byte[] types, if you want. Of course, it belongs to a strongly typed array.
Use the following statement to create a byte array with an array element number of 100.
Copy Code code as follows:
$byteArray = new-object byte[] 100
Creates a byte array with 100 array elements and a value of 0xFF for each array element.
Copy Code code as follows:
$byteArray = [byte[]] (, 0xFF * 100)
To explain here, byte[] represents a byte type, and the byte[is then enclosed in brackets to denote an array type. 0xFF is a byte value of 255, using commas to denote the delimiter of an array element, except that there is a 0xFF array element. "* 100" means to repeat the preceding array element 100 times. So ultimately the meaning of this expression is to create an array of 100 elements, each with a value of 0xFF.
Here's an example of how the array uses the "* number" when it assigns values.
Copy Code code as follows:
$array = (1..7) * 5
(1..7) 1,2,3,4,5,6,7 These seven arrays, "* 5" means to repeat this 1 to 7 sequence again 5 times! So, this array has 35 elements at the end.
About PowerShell to create a byte array, small series on the introduction of so many, hope to help everyone.