tags:

views:

148

answers:

1

The obvious doesn't catch the LF characters

foo.Replace(Environment.NewLine, String.Empty)

Nor does...

foo.Replace("\r\n", "").Replace("\n", "").Replace("\r", "")

The file itself is a multi line XML file. Line feed characters before the XML declaration invalidate the string.

+4  A: 

VB.NET doesn't use the C style escapes for CR or LF. In VB, your second example translates to:

foo.Replace(vbNewLine, replaceWith).Replace(vbLF, replaceWith).Replace(vbCR, replaceWith)
Mark Brackett
+1 Obviously it needs to be `bah=foo.Replace(...)` as Replace doesn't change the string
MarkJ
just to add, foo = foo.Replace if you want the contents of foo to change
CResults