这是我的第一篇文章!
我不是一个特别自信的程序员,但我到了那里.
static Dictionary<string,Dictionary<string,List<string>>> testDictionary = ...
如果Dictionary不包含当前键(字符串),我可以轻松添加键和另一个已填充的字典,如此…
testDictionary.Add(userAgentResult,allowdisallowDictionary);
这工作正常,当我尝试添加内部字典时,如果userAgentResult Key已经存在,我的问题就来了.
我希望这样做……
testDictionary[userAgentResult].Add(allowdisallowDictionary);
但.Add方法需要两个参数,即字符串键和列表值.所以我继续写这段代码……
//this list as the dictionary requires a list List<string> testDictionaryList = new List<string>(); //this method returns a string testDictionaryList.Add(regexForm(allowResult,url)); //this will add the key and value to the inner dictionary,the value,and then //add this value at the userAgentKey testDictionary[userAgentResult].Add(allowdisallowKey,testDictionaryList);
解决方法
原文地址:https://www.jb51.cc/csharp/92249.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。