如何在PowerShell中将Dictionary转换为Hashtable?
与PowerShell中的任何其他数据类型转换一样,我们可以通过类似的方式将Dictionary转换为hashtable。对于示例,我们在下面的词典中称为$CityData。
Key Value --- ----- India 91 Austria 43
它的数据类型是Dictionary,
示例
PS C:\> $citydata.GetType() | ft -AutoSize输出结果
IsPublic IsSerial Name BaseType -------- -------- ---- -------- True True Dictionary`2 System.Object
要将其转换为哈希表,
$hash = [Hashtable]$citydata
要么
$hash = [System.Collections.Hashtable]$CityData
数据类型:
PS C:\> $hash | ft -AutoSize输出结果
Name Value ---- ----- Austria 43 India 91
热门推荐
10 祝女儿简短祝福语大全
11 大学新年祝福语简短创意
12 元旦适合的祝福语简短
13 朋友出远门祝福语简短
14 初六简短的祝福语
15 祝男孩生日祝福语简短
16 同事调离的祝福语简短
17 拜年红包的祝福语简短
18 妈妈生日祝福语简短励志