的App.config:爲什麼我的字典爲字符串添加額外的轉義字符?
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="1" value="An error occured.\r\nPlease try again later." />
</appSettings>
</configuration>
代碼:
Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
string key = "1";
keyValuePairs.Add(key, ConfigurationManager.AppSettings["key"]);
if (keyValuePairs.ContainsKey(key))
{
// when I hover over the object, keyValuePairs, in my debugger, I see, "An error occured.\r\nPlease try again later."
string value1 = keyValuePairs[key];
// now when I hover over the local variable, value, I see, "An error occured.\\r\\nPlease try again later."
}
我很好奇,爲什麼上面的代碼添加轉義字符爲 「\ r \ n」 來使其「\ r \ n「
我也想知道如何避免獲得額外的」\「字符。
如果使用'Environment.NewLine',會發生什麼? – DaveDev 2010-09-03 00:19:05
我不能把'Environment.NewLine'放在我的App.config中 – JohnB 2010-09-03 00:30:26
https://connect.microsoft.com/VisualStudio/feedback/details/594160/consider-displaying-strings-in-the-debugger-without-escaping – Timwi 2010-09-03 02:07:43