powershell - 如何在powershel脚本中将链接的.net调用分成多行?
问题描述
很少有答案可以显示像这样的不同的多行技巧,但是如果可能的话,没有任何解释可以解释如何实现这种代码格式
set-content $file $fll.Replace("Long line 1", "Very Long line 1")
.Replace("Long line 2", "Very Long line 2")
.Replace("Long line 3", "Very Long line 3")
.Replace("Long line 4", "Very Long line 4")
.Replace("Long line 5", "Very Long line 5")
如果Replace
以上内容链接在一行中 - 它可以工作
解决方案
对于您发布的特定代码片段,不仅仅是打破跨行链式 .NET 调用的一般情况:
[1] 将点放在.
右括号之后。(打破任何.NET 跨行调用的一般情况)
[2] 将第二个参数Set-Content
括在括号中。
Set-Content $file (
$fll.Replace("Long line 1", "Very Long line 1").
Replace("Long line 2", "Very Long line 2").
Replace("Long line 3", "Very Long line 3").
Replace("Long line 4", "Very Long line 4").
Replace("Long line 5", "Very Long line 5")
)
推荐阅读
- java - 将 Java SWT/AWT 桥嵌入到 winform 表单中
- arrays - 谷歌电子表格中的总和((关闭 2 - 关闭 1)/关闭 1)
- module - Why Isn't This Module Visible?
- reactjs - 使用 Yup 和 Formik 自动修剪空白
- java - 如何将整数和字符数组输入到需要字符和整数的方法中
- c# - 我想使用 Element at , length 和 substring 方法从 c# 中的字符串中删除一些东西
- ckeditor - Vue 组件内的 CkEditor 工具栏配置
- angular - 获取文件输入类型的值返回空 - 角度
- git - git ls-files 排除目录中的文件
- python - 有什么方法可以从 CSV 文件中解析正确的日期行吗?