如何在 powershell 中声明 System.Collections.Generic.IDictionary
How to declare a System.Collections.Generic.IDictionary in powershell
在 Powershell 中,我需要将输入传递给 System.Collections.Generic.IDictionary[string, system.object].
类型的方法
有人可以帮我提供有关如何声明 IDictionary[string,system.object] 并为其设置值的示例代码。
类似于:
$dict = New-Object 'system.collections.generic.dictionary[[string],[object]]
中给出的另一种方法。
$dict = [System.Collections.Generic.Dictionary[string,object]]::new()
一种表达能力较差但相当简洁的方式是空哈希表。
$dict = @{}
从中遵循一种设置数据的方法。
$dict = @{"badger"="Mustelidae"; "tiger"="Panthera"; "snake"="Serpentes"}
可以添加或更新单个值。
$dict.badger = "Mustelidae"
在 Powershell 中,我需要将输入传递给 System.Collections.Generic.IDictionary[string, system.object].
类型的方法有人可以帮我提供有关如何声明 IDictionary[string,system.object] 并为其设置值的示例代码。
类似于:
$dict = New-Object 'system.collections.generic.dictionary[[string],[object]]
$dict = [System.Collections.Generic.Dictionary[string,object]]::new()
一种表达能力较差但相当简洁的方式是空哈希表。
$dict = @{}
从中遵循一种设置数据的方法。
$dict = @{"badger"="Mustelidae"; "tiger"="Panthera"; "snake"="Serpentes"}
可以添加或更新单个值。
$dict.badger = "Mustelidae"