任何人都可以幫助我嗎?問題與詞典<字符串,字符串>
我做了一個簡單的代碼:
private void ObterRelatorios(string id) {
var relatorios = new Dictionary<string, string>();
var xml = new XmlDocument();
xml.Load("my_path");
foreach (XmlNode node in relatoriosStaticos.DocumentElement.ChildNodes)
relatorios.Add(node.Attributes["Titulo"].InnerText, string.Concat(node.Attributes["Url"].InnerText, id));
}
我的XML是5個節點很簡單,始終是一樣的。
這是奇怪的,因爲有時工作,有時不是。
這是我得到拋出一個異常
錯誤詳細信息時:
Exception of type 'System.Web.HttpUnhandledException' was thrown.
完整的堆棧:
[ArgumentNullException: Value cannot be null.
Parameter name: key]
at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
at System.Collections.Generic.Dictionary.Insert(TKey key, TValue value, Boolean add)
at System.Collections.Generic.Dictionary.Add(TKey key, TValue value)
感謝您編輯我的文章! –