我一直在 PowerShell 中推进 .NET 框架,但遇到了一些我不明白的问题。这工作正常:
$foo = New-Object "System.Collections.Generic.Dictionary``2[System.String,System.String]"
$foo.Add("FOO", "BAR")
$foo
Key Value
--- -----
FOO BAR
然而,这并没有:
$bar = New-Object "System.Collections.Generic.SortedDictionary``2[System.String,System.String]"
New-Object : Cannot find type [System.Collections.Generic.SortedDictionary`2[System.String,System.String]]: make sure t
he assembly containing this type is loaded.
At line:1 char:18
+ $bar = New-Object <<<< "System.Collections.Generic.SortedDictionary``2[System.String,System.String]"
它们都在同一个程序集中,那么我错过了什么?
正如答案中所指出的,这几乎只是 PowerShell v1 的问题。
在 PowerShell 2.0 中创建Dictionary
is:
$object = New-Object 'system.collections.generic.dictionary[string,int]'
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)