Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Winforms 如何在包含变量的变量名中存储信息?_Winforms_Powershell - Fatal编程技术网

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
附加到
获取变量
谢谢它工作得很好我只是愚蠢地实现了它谢谢它工作得很好我只是默默地实施它