If not what is the best way to determine if two NameValueCollections objects are equal.
I am using it to determine if two query strings parsed into a namevaluecollection have the same keys and values regardless of order.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Equals does not appear to do what you want. It appears to check reference equality, not that they are equivalent.
The following method should work (using System.Linq), though there’s probably a more efficient way:
Note: If order does matter, the OrderBy statements could be dropped. If there are multiple values per key and you need to check that values are equivalent regardless of order, then the last line could be changed to something like: