function test1{
param([System.Collections.ArrayList]$x
)
$x.Add("Test1Add")
write "in Test1 $x"
}
$x=New-Object System.Collections.ArrayList
Here is my code , after I run test1, Result would be:
PS C:\Windows> test1 $x
0
in Test1 Test1Add
PS C:\Windows> $x
Test1Add
I am wondering why this happens, I guess when invoke test1, It just like passing a pointer of a Reference type to test1, Just like C# or other language? Value type like int, I must use $script:x to change the x in the gloabl scope . Thanks in advance