I just created a simple function "f" that adds an pscustomobject element into an arraylist, but when displaying it, result is not what I expected:
$c=New-Object System.Collections.ArrayList($null)
function f([string]$a1,[string]$a2)
{
$c.Add([PSCustomObject]@{item1=$a1;item2=$a2})
}
f("kkk","aaa")
$c
result is:
item1 item2
----- -----
kkk aaa
It seems to me that both "kkk" and "aaa" goes to item1, if I type
$c.item1
it prints
kkk aaa
Why? I expect item1 to be "kkk" and item2 to be "aaa".