如何在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 教师闺蜜祝福语简短