向文本框添加空格c#
我的文本框中有很多文本(我正在尝试解决作业的加密问题),但我已经以一种非常不清楚的方式将其布局了!在每个 | 之前和之后插入四个空格的最简单方法是什么?特点?
谢谢。
I have a lot of text in a text box (im trying to solve an encryption for homework) but i have laid it out in a fashion thats pretty unclear! What is the easiest way to insert four spaces before and after every | character?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
有很多方法可以做到这一点,但最简单的可能是
string.replace("|", " | ");
Lots of ways to do this but the simplest is probably
string.replace("|", " | ");
txtMyText.Text = txtMyText.Text.Replace("|", " | ");
这可能有效吗?
txtMyText.Text = txtMyText.Text.Replace("|", " | ");
This might work?
也许最简单的方法是对字符串进行替换:
Probably the easiest way would be to do a
Replace
on the string:这不是最优雅的解决方案,但我认为您能够理解它。
您只需传入文本框的值并将其返回的内容设置为文本即可。
Not the most elegant solution but I think that its one you will be able to understand.
You just need to pass in the value of the textbox and set what it returns as the text.