【发布时间】:2010-10-11 16:09:27
【问题描述】:
我有一个场景,我可以使用 NameValueCollection 或 IDictionary。但我想知道哪一个在性能方面会更好。
-- 使用 NameValueCollection
NameValueCollection options()
{
NameValueCollection nc = new NameValueCollection();
nc = ....; //populate nc here
if(sorting)
//sort NameValueCollection nc here
return nc;
}
-- 使用字典
IDictionary<string, string> options()
{
Dictionary<string, string> optionDictionary = new Dictionary<string, string>();
optionDictionary = ....; //populate
if(sorting)
return new SortedDictionary<string, string>(optionDictionary);
else
return optionDictionary;
}
【问题讨论】: