The C# compiler interpolates special character literals like \t for tab, \n for newline etc. But is there a built-in C# or .Net function that can interpolate them at runtime?
For example, at runtime I read a configuration for a text-delimited file format, maybe something like this:
Delimiter: \t
LineEnding: \r\n
Right now the only thing I can think of doing is reading in the string and then performing a Replace() with compiler-interpolated strings:
Delimiter = Delimiter.Replace(@"\n", "\n").Replace(@"\r", "\r");
You can try
Regex.Unescapewhich possible satisfies all your requirements.From MSDN: