Par*_*rsa 13 generics powershell powershell-2.0
我如何在PowerShell 2中创建一个列表?我试过这些:
[activator]::createinstance(([type]'system.collections.generic.list`1').makegenerictype([string]))
Run Code Online (Sandbox Code Playgroud)
和
[activator]::createinstance(([type]'system.collections.generic.list`1').makegenerictype([string]))
Run Code Online (Sandbox Code Playgroud)
而我得到的只是一无所获.出了什么问题?
我正在运行XP SP3,如果重要的话
Kei*_*ill 19
试试这个:
PS> $list = New-Object 'System.Collections.Generic.List[string]'
PS> $list.Add('foo')
PS> $list
foo
PS> $d = New-Object 'System.Collections.Generic.Dictionary[string,datetime]'
PS> $d.Add('moonshot', [datetime]'7/20/1969')
PS> $d['moonshot']
Sunday, July 20, 1969 12:00:00 AM
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11980 次 |
| 最近记录: |