PowerShell Create a byte array example _powershell

Source: Internet
Author: User
Tags array example

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.