Is there a quick and simple way to check if a key exists in a NameValueCollection without looping through it?
Looking for something like Dictionary.ContainsKey() or
From MSDN:
This property returns null in the following cases:
1) if the specified key is not found;
So you can just:
NameValueCollection collection = ...
string value = collection[key];
if (value == null) // key doesn't exist
2) if the specified key is found and its associated value is null.
collection[key] calls base.Get() then base.FindEntry() which internally uses Hashtable with performance O(1).