在文本框中每行的开头和结尾添加新字符
我有一个启用了多行的文本框,并且想要在开头和结尾添加一个字符串 每一行,因此每一行都会更改为
a + line + b
Now I Know it has to do with a foreach 循环,但不知道如何写出来。
I have a textbox with multiline enabled, and want to add a string at the beginning and end of
each line, so every line would be changed to
a + line + b
Now I know it has to do with a foreach loop, but don't know how to write it out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
好吧,
行
属性可能就是您想要的。三个选项:或:
或:
Well, the
Lines
property is probably the one you want. Three options:Or:
Or:
您可以对整个文本使用替换:
You can use a replace on the entire text:
既然你提到了 foreach,这里还有另一种方法。
Since you mentioned foreach, here's another way.
这是我用来将字符 a 和 b 添加到包含一堆行的字符串的开头和结尾的方法:
Here is what i use to add the characters a and b to the beginning and the end to a string that contains a bunch of lines :