Possible Duplicate:
Can I convert a C# string value to an escaped string literal
How can I print a string (via Console.WriteLine()) such that any/all escape sequences that may exist in the string is printed verbatim?
Example:
string s = "This \r\n has \t special \\ characters.";
Console.WriteLine(s);
/* Output (I don't want this)
This
has special \ characters.
*/
I want the output to read:
This \r\n has \t special \\ characters.
Note that in my application I am receiving the string (which contains the escape sequences) from a third party - i.e. If I were creating the string myself, I'm aware that I could just do
string s = @"This \r\n has \t special \\ characters.";