NameValueCollection ile Dictionary arasındaki fark

Hasan Akpürüm

Kıdemli Yazılım Danışmanı

NameValueCollection ile Dictionary arasındaki fark

Yayınlanma 01 Ocak 0001
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. We will contact you shortly!

Yorumu Gönder