String.Format value in App.config creates extra backslash
Here's the line from App.Config:
<add key="CheckFileFormatString" value="P{0}\t"{1}, {2}"\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}"/>
Here's the code that puts it on a line (please ignore the legacy call .AppSettings.Get
if that's the only problem):
string format = ConfigurationSettings.AppSettings.Get("CheckFileFormatString");
... and here's the resulting line:
P{0}\\t\"{1}, {2}\"\\t{3}\\t{4}\\t{5}\\t{6}\\t{7}\\t{8}\\t{9}\\t{10}
Where is the extra backslash added?
+2
source to share
2 answers
The extra backslash comes from how the debugger displays the value.
The string value is offset in the same way that you can write it as a string literal in your code, so every backslash in the string appears as \.
The backslashes in your string come from the XML value, since the backslash is not an escape character in XML. As Richard explained, you need to use 	
to get the tab character in the XML value.
+1
source to share