【发布时间】:2012-05-24 18:50:37
【问题描述】:
我正在尝试查找字符串中出现的每个 ASCII 字符并将其替换为新行。这是我目前所拥有的:
public string parseText(string inTxt)
{
//String builder based on the string passed into the method
StringBuilder n = new StringBuilder(inTxt);
//Convert the ASCII character we're looking for to a string
string replaceMe = char.ConvertFromUtf32(187);
//Replace all occurences of string with a new line
n.Replace(replaceMe, Environment.NewLine);
//Convert our StringBuilder to a string and output it
return n.ToString();
}
这不会添加新行,并且字符串都保留在一行上。我不确定这里有什么问题。我也试过了,但结果一样:
n.Replace(replaceMe, "\n");
有什么建议吗?
【问题讨论】:
-
我们也“不确定问题出在哪里”。因为你没有告诉我们。
-
什么问题?和什么结果一样?
-
它没有按照我说的去做......