function ExtractLocations([ref]$lp_Locations) { $lp_Locations.Value = "A STRING VALUE" return 0 } ... $Locations = "" if (@(ExtractLocations([ref]$Locations)) -ne 0) { RecordErrorThenExit }
$Locations 总是以空字符串结尾 .
$Locations
除了@ mklemen0所说的,设置值,你不需要像 $Variable.Value = 'Something' 那样做,它只是 $Variable = 'Something'
$Variable.Value = 'Something'
$Variable = 'Something'
使用 @() 表达式,您将输出转换为不需要的数组 . PowerShell中不建议声明与c#中的方法类似的函数 . 你可以像下面这样做 .
@()
function ExtractLocations{ Param([ref]$lp_Locations) $lp_Locations = "A STRING VALUE" return 0 } ExtractLocations -lp_Locations ([ref]$Locations)
1 回答
除了@ mklemen0所说的,设置值,你不需要像
$Variable.Value = 'Something'
那样做,它只是$Variable = 'Something'
使用
@()
表达式,您将输出转换为不需要的数组 . PowerShell中不建议声明与c#中的方法类似的函数 . 你可以像下面这样做 .