The following is a class that will format a string as a querystring:
public class QueryStringFormatter { private Dictionary<string, string> _Items = new Dictionary<string, string>(); public Dictionary<string, string> Items { get { return _Items; } set { _Items = value; } } public override string ToString() { string retVal = string.Empty; if (_Items.Count > 0) { List<string> list = new List<string>(); foreach (KeyValuePair<string, string> kvp in _Items) { list.Add(string.Format("{0}={1}", kvp.Key, kvp.Value)); } retVal = "?" + string.Join("&", list.ToArray()); } return retVal; } }