小编n3o*_*n3o的帖子

c#在文本框中用换行符替换“\n”文本

我有一些文本(例如“o\nour first place, and this\n\n13”),我希望文本中的每个“\n”字符串都必须用换行符替换...

该示例的输出将是:

o 我们的第一名,还有这个

13 我怎么做?文本框是多行的

代码是

string text_str = txtbox.Text;
text_str .Replace("(?<!\r)\n", "\r\n");
txtbox.Clear();
txtbox.Text = text_str;
Run Code Online (Sandbox Code Playgroud)

c# textbox replace newline

1
推荐指数
1
解决办法
9344
查看次数

标签 统计

c# ×1

newline ×1

replace ×1

textbox ×1