[英]How do I store information in a variable name that contains a variable?
您可以使用Set-Variable
或Invoke-Expression
。
Set-Variable -Name "Button$Type" -Value "test"
Invoke-Expression "`$Button$Type = 'test'"
但我建议使用哈希表,因为它安全且快速。
$h = @{}
$h."Button$Type" = "test"
$h.ButtonApp2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.