Search code examples
c#resource-files

How can I not escape a character sequence in a string in C#?


I am reading in a value from a resource file (.resx) in C# and in that value, I have added \r\n\r\n so that it gets displayed in the correct format. e.g. blah\r\n\r\nblah For some reason, the string automatically adds a '\' so effectively text becomes blah\\r\\n\\r\\nblah and thus it escapes the character sequences.


Solution

  • Try to use Shift+Enter to add a new line in .resx file instead of \r\n. Or replase like str = str.Replace("\\r\\n", "\r\n");