【发布时间】:2017-01-20 20:06:37
【问题描述】:
我的代码
[System.Collections.ArrayList]$Global:shells=@()
$cmdProc = Start-Process powershell -ArgumentList "-noexit", ("-command grunt "+ [string]$argList) -WorkingDirectory $fwd -PassThru
[System.Collections.ArrayList]$Global:shells.Add(($cmdProc))
确实将 PowerShell 进程添加到 $shells arrayList。但它也会显示一条错误消息:
无法将“System.Int32”类型的“0”值转换为类型 “System.Collections.ArrayList”。 在行:16 字符:1 + [System.Collections.ArrayList]$Global:shells.Add(($cmdProc))
它肯定与它添加的arrayList的索引有关,但这是怎么回事?我可以访问$shells[0] 就好了。
【问题讨论】:
标签: powershell arraylist