2008-08-24 27 views

回答

17

为什么不:

string s = "foobar\ngork"; 
string v = s.Replace(Environment.NewLine,","); 
System.Console.WriteLine(v); 
0

,最好的办法就是内建的方法:使用string.Replace。为什么你需要替代品?

2
string sample = "abc" + Environment.NewLine + "def"; 
string replaced = sample.Replace(Environment.NewLine, ","); 
2

不要重新发明轮子 - 只需使用myString.Replace(Environment.NewLine “”)

7

像这样:

string s = "hello\nworld"; 
s = s.Replace(Environment.NewLine, ","); 
相关问题