如何在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 虎年孩子说简短祝福语