我有以下代码:
$project.PropertyGroup | Foreach {
if($_.GetAttribute('Condition').Trim() -eq $propertyGroupConditionName.Trim()) {
$a = $project.RemoveChild($_);
Write-Host $_.GetAttribute('Condition')"has been removed.";
}
};
Run Code Online (Sandbox Code Playgroud)
问题1:如何退出ForEach?我尝试使用"break"和"continue",但它不起作用.
问题2:我发现我可以在一个foreach循环中改变列表...我们不能像在C#中那样做...为什么PowerShell允许我们这样做?