c# - Problems with replacing "\" character -


maybe can me following problem. have text containing "\line" username \line firstname \line. want replace \r\n. code:

string _text = query; _text.replace("\line", " \r\n"); 

it gives following error: unrecognized escape sequence.

anyone wit solution?

thanks!

you need escape backslash

_text.replace("\\line", " \r\n"); 

alternatively try string literal (haven't tried though):

_text.replace(@"\line", " \r\n"); 

Comments