Winforms 如何在包含变量的变量名中存储信息?
现在更明显的是,我打算调用一个函数,该函数除了给定的变量之外什么都不做Winforms 如何在包含变量的变量名中存储信息?,winforms,powershell,Winforms,Powershell,现在更明显的是,我打算调用一个函数,该函数除了给定的变量之外什么都不做 非常感谢您,您不知道您帮了我多少忙您可以使用设置变量或调用表达式 $DataApp2 = "SUCCESS FINALLY" $Type = "App2" $Data = Get-Variable -Name "Data$Type" -Value Set-Variable -Name "Button$Type" -Value "$Data" $ButtonName = Get-Variable -Name "Button$
非常感谢您,您不知道您帮了我多少忙您可以使用
设置变量
或调用表达式
$DataApp2 = "SUCCESS FINALLY"
$Type = "App2"
$Data = Get-Variable -Name "Data$Type" -Value
Set-Variable -Name "Button$Type" -Value "$Data"
$ButtonName = Get-Variable -Name "Button$Type" -Value
$DefaultForm.Text = "$ButtonName"
但我建议使用哈希表,因为它既安全又快速
Invoke-Expression "`$Button$Type = 'test'"
您可以使用
设置变量
或调用表达式
$DataApp2 = "SUCCESS FINALLY"
$Type = "App2"
$Data = Get-Variable -Name "Data$Type" -Value
Set-Variable -Name "Button$Type" -Value "$Data"
$ButtonName = Get-Variable -Name "Button$Type" -Value
$DefaultForm.Text = "$ButtonName"
但我建议使用哈希表,因为它既安全又快速
Invoke-Expression "`$Button$Type = 'test'"
要让
$ButtonName
返回测试
将参数-Value
附加到获取变量
要让$ButtonName
返回测试
将参数-Value
附加到获取变量
谢谢它工作得很好我只是愚蠢地实现了它谢谢它工作得很好我只是默默地实施它