Jerry,
The original message didsn't specify any such thing. The author used "CRLF"
in the title, but obviously didn't know exactly what he was looking for,
other than a method to replace new line character/combination in a string.
Using Environment.Newline will return the correct new line character or
combination for whatever platform one is working on, and is the safest thing
to use. That is what it's for. My advice was correct.
--
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
http://www.takempis.com
The more I learn, the less I know.
Jerry III said:
Kevin that depends, the original question was how to replace CRLF pairs, not
platform specific new line character(s).
Jerry
creates
a
new
one (which you have to store and use instead of the original string),
don't
you? And that your code posted below only replaces carriage returns, not
CRLF pairs?
Jerry
After my testing, it cannot work. I write a method to do this.
public static string Display(string BodyText)
{
StringBuilder retVal = new StringBuilder();
if ((BodyText != null) && (BodyText != String.Empty))
{
for (int i = 0; i < BodyText.Length; i++)
{
switch (BodyText)
{
case '\r':
retVal.Append("<BR>");
break;
default:
retVal.Append(BodyText);
break;
}
}
}
return retVal.ToString();
}