【发布时间】:2012-04-07 22:57:22
【问题描述】:
我正在使用 Windows 7 和 PowerGUI 脚本编辑器来编写一个 ps1。 这是我的部分代码:
#In global scope
$Type_Trans = "System.Collections.Generic.Dictionary[System.String,PSObject]"
$Type_Farms = "System.Collections.Generic.Dictionary[System.Int32,$Type_Trans]"
$Dic_Counts = New-Object $Type_Farms
#...puts some data in $Dic_Counts here...
#It is no problem with printing out it in console
#Now call the function below
Write-Data $Dic_Counts
Function Write-Data
{
param(
$Dic_Counts
)
Foreach($Dic_CountsSingle in $Dic_Counts)
{
Write-DataSingle $Dic_CountsSingle #THIS LINE!
}
}
这里很奇怪:为什么Dic_CountsSingle不是KeyValuePair,而是和Dic_Counts一样??
非常感谢!
【问题讨论】:
标签: .net loops powershell dictionary