Source

main-vinayFork / Source / WebClient / Web.Client / Infrastructure / NameValueCollectionExtensions.cs

Full commit
using System.Collections.Specialized;
using System.Globalization;
using System.Linq;
using System.Web;

namespace DataUp.Web.Client.Infrastructure
{
    public static class NameValueCollectionExtensions
    {
        /// <summary>
        /// Greates query string using the name value collection
        /// </summary>
        /// <param name="collection"></param>
        /// <returns></returns>
        public static string ToQueryString(this NameValueCollection collection)
        {
            return string.Join("&",
                from k in collection.AllKeys
                select string.Format(CultureInfo.InvariantCulture,
                    "{0}={1}",
                    k,
                    HttpUtility.UrlEncode(collection.GetValues(k)[0])));
        }
    }
}