Compare Two NameValueCollections Extension Method

Posted by Jon Canning on Geeks with Blogs See other posts from Geeks with Blogs or by Jon Canning
Published on Thu, 16 Jun 2011 20:57:50 GMT Indexed on 2011/06/20 16:24 UTC
Read the original article Hit count: 271

Filed under:
    public static class NameValueCollectionExtension
    {
        public static bool CollectionEquals(this NameValueCollection nameValueCollection1NameValueCollection nameValueCollection2)
        {
            return nameValueCollection1.ToKeyValue().SequenceEqual(nameValueCollection2.ToKeyValue());
        }
 
        private static IEnumerable<objectToKeyValue(this NameValueCollection nameValueCollection)
        {
            return nameValueCollection.AllKeys.OrderBy(x => x).Select(x => new {Key = xValue = nameValueCollection[x]});
        }
    }

 

 

© Geeks with Blogs or respective owner