I have a scenario where-in I can use either NameValueCollection or IDictionary. But I would like to know which one will be better performance-wise.
-- Using NameValueCollection
NameValueCollection options()
{
NameValueCollection nc = new NameValueCollection();
nc = ....; //populate nc here
if(sorting)
//sort NameValueCollection nc here
return nc;
}
-- using IDictionary
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;
}