Hasan Akpürüm
blog-post-1

NameValueCollection ile Dictionary arasındaki fark

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