如果您尝试基于字符串创建列表,请尝试以下操作:
New-Object 'System.Collections.Generic.List[system.string]'
请注意,您必须指定'system.string'(至少在我的comp ;))。如果您只使用“字符串”,则会引发异常。
[61]: New-Object 'System.Collections.Generic.List[string]'
New-Object : Cannot find type [System.Collections.Generic.List[string]]: make sure the assembly containing this type is loaded.
At line:1 char:11
+ New-Object <<<< 'System.Collections.Generic.List`1[string]'
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand