Yes, you can use Linq to check the AllKeys
property:
using System.Linq;
...
collection.AllKeys.Contains(key);
However a Dictionary<string, string[]>
would be far more suited to this purpose, perhaps created via an extension method:
public static void Dictionary<string, string[]> ToDictionary(this NameValueCollection collection)
{
return collection.Cast<string>().ToDictionary(key => key, key => collection.GetValues(key));
}
var dictionary = collection.ToDictionary();
if (dictionary.ContainsKey(key))
{
...
}