这里简单的代码...
$array = @()
$numbers = 1..5
foreach ($number in $numbers) {
$info = "" | select number,result,test
$info.number = $number
$info.result = $number.ToString() + "-result"
$array+=$info
$info
}
[System.Collections.ArrayList]$arraylist = $array
$arraylist[0].test = "true"
但是,每当我修改上面的$ arraylist [0]时,它也会同时修改$ array [0]
PS C:\Users\testuser> $array[0]
number result test
------ ------ ----
1 1-result true
PS C:\Users\testuser> $arraylist[0]
number result test
------ ------ ----
1 1-result true
如何阻止这种情况的发生?我想保持原始数组不变,只修改ArrayList吗?