Hasan Akpürüm
Kıdemli Yazılım Danışmanı
Makele Detayı

NameValueCollection ile Dictionary arasındaki fark

15.8.2012 23:48:32
NameValueCollection tested

var collection = new NameValueCollection();
collection.Add("Sam", "Dot Net Perls");
collection.Add("Bill", "Microsoft");
collection.Add("Steve", "Apple");
collection.Add("Rupert", "News Corporation");

Dictionary tested

var dictionary = new Dictionary<string, string>();
dictionary.Add("Sam", "Dot Net Perls");
dictionary.Add("Bill", "Microsoft");
dictionary.Add("Steve", "Apple");
dictionary.Add("Rupert", "News Corporation");

NameValueCollection statement tested

string value = collection["Steve"];

Dictionary statement tested

string value = dictionary["Steve"];

Results: 10 million iterations

NameValueCollection lookup: 2768 ms
Dictionary lookup:           407 ms [faster]
Yorum yaz

Thanks, your message is sent successfully.