2008-08-24 28 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, ","); 
相關問題