【发布时间】:2020-01-29 17:58:48
【问题描述】:
我可以在哈希表中设置表单元素:
$Hash = @{}
$Hash.Main = New-Object System.Windows.Forms.Form
$Hash.Main.Left = 0
$Hash.Main.Top = 0
...
$Hash.Label = New-Object System.Windows.Forms.Label
$Hash.Label.Left = 0
$Hash.Label.Top = 0
...
$Hash.Panel = New-Object System.Windows.Forms.Panel
$Hash.Panel.Left = 0
$Hash.Panel.Top = 0
...
我怎样才能在哈希表中写同样的东西?我试着让它好像可以。它有效。但是这个语法正确吗?
$Hash = @{
Main = [System.Windows.Forms.Form] @{
Left = 0
Top = 0
...
}
Label = [System.Windows.Forms.Label] @{
Left = 0
Top = 0
...
}
Panel = [System.Windows.Forms.Panel] @{
Left = 0
Top = 0
...
}
}
谢谢
【问题讨论】:
-
也许我遗漏了一些东西,但为什么不采取第二个代码块并尝试一下看看它是否有效或产生语法错误?
标签: winforms powershell hashtable