相关疑难解决方法(0)

PowerShell通用集合

我一直在推动PowerShell中的.NET框架,我遇到了一些我不理解的东西.这很好用:

$foo = New-Object "System.Collections.Generic.Dictionary``2[System.String,System.String]"
$foo.Add("FOO", "BAR")
$foo

Key                                                         Value
---                                                         -----
FOO                                                         BAR
Run Code Online (Sandbox Code Playgroud)

然而,这不是:

$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]"
Run Code Online (Sandbox Code Playgroud)

他们都在同一个集会,所以我错过了什么?

正如答案中指出的那样,这只是PowerShell v1的一个问题.

.net powershell powershell-1.0

36
推荐指数
2
解决办法
4万
查看次数

标签 统计

.net ×1

powershell ×1

powershell-1.0 ×1