Build Query String - CSharp System

CSharp examples for System:String Convert

Description

Build Query String

Demo Code


using System.Text;
using System.Runtime.CompilerServices;
using System.Reflection;
using System.Linq;
using System.Globalization;
using System.Collections.Generic;
using System;//  ww w. j  ava2  s .c  o m

public class Main{
        public static string BuildQueryString(Dictionary<string, string> values)
        {
            var sb = new ExtendedStringBuilder();

            foreach (var kvp in values)
            {
                if (sb.Length > 0)
                {
                    sb += '&';
                }

                sb.Append(kvp.Key).Append('=').Append(kvp.Value);
            }

            return sb;
        }
}

Related Tutorials