Вы находитесь на странице: 1из 5

about_Arrays

. Windows PowerShell
, string, int (32-
), long (64- ), bool (
), byte, Microsoft .NET.


,
.
, ,
(=).

, $A,
( int), 22, 5, 10, 8, 12, 9 80,
:

$A = 22,5,10,8,12,9,80

,
(..). ,
"$B", 5 8,
:

$B = 5..8

$B : 5, 6, 7 8.

, Windows PowerShell
(: object[]).
GetType(). ,
$a, :

$a.gettype()

, ,
,
, , string[], long[] int32[].
,
. ,
32- $ia,
(1500, 2230, 3350 4000), :

[int32[]]$ia = 1500,2230,3350,4000

, $ia
.

, ,
Microsoft .NET. , ,
Get-Process ,
System.Diagnostics.Process.
, :
[Diagnostics.Process[]]$zz = Get-Process


, . ,
,
, "co".

$LocalProcesses = get-process co*

,
$LocalProcesses .
,
(@), :

$LocalProcesses = @(get-process co*)

,
$LocalProcesses .
,
. , .
. about_Operators.


,
, $A $a. Windows PowerShell
.

, . :

$a


, 0. .
, $a,
:

$a[0]

$a, :

$a[2]

.
, "-1" .
, :

$a[-3..-1]

$a[0..-2]

.
,
.
,
. ,
1 3, :

$a[1..3]


, "+". ,
0, 2, 4 6,
:

$a[0,2+4..6]

,
lentgh. ,
2 , :

$a[2..($a.length-1)]

,
0. (1, 2 3)
2, ,
.


, , Foreach, For While. ,
Foreach $a,
:

foreach ($element in $a) {$element}

Foreach
, .

For
. ,
For, :

for ($i = 0; $i -le ($a.length - 1); $i += 2) {$a[$i]}

While
, . ,
$a, 4,
:

$i=0
while($i -lt 4) {$a[$i]; $i++}

, ,
Length SetValue, InputObject
Get-Member.
Get-Member ,
. InputObject
.

$a
:
get-member -inputobject $a


, ,
.

,
, ,
(=),
. , 10
$a ( 1), :

$a[1] = 10

,
SetValue. $a ( 1)
500:

$a.SetValue(500,1)


"+=".

.
, .
,
. ,
200 $a, :

$a += 200

,
,
. , $t,
$a 2,
:

$t = $a[0,1 + 3..($a.length - 1)]

, "+".
; ,
:

$x = 1,3
$y = 5,9
$z = $x + $y

$z 1, 3, 5 9.

, Remove-Item
, .
"a" Variable:.

remove-item variable:a

( Variable:,
. " Variable".)
.
about_Assignment_Operators
about_Hash_Tables
about_Operators
about_For
about_Foreach
about_While

Оценить