Given this sample code:
var s = "abc\r\ndef";
foreach (var c in s)
{
Console.WriteLine($"Current char: {c}");
}
Of course, the '\r'
and '\n'
characters, are written as whitespace and an actual newline, respectively. What I want to achieve is to write '\r'
, '\n'
instead.
What's the easiest way to convert a character to it's (C#) 'escaped representation'? Should I look at Roslyn for this, or is there a simple conversion function available?