Get or set a collection of query name/value pairs associated with the request in CSharp
Description
The following code shows how to get or set a collection of query name/value pairs associated with the request.
Example
using System;//w ww . j a va 2 s . c o m
using System.Net;
using System.Net.Sockets;
using System.Collections.Specialized;
public class Example
{
public static void Main()
{
string uriString = "http://www.google.com/search";
WebClient myWebClient = new WebClient();
NameValueCollection myQueryStringCollection = new NameValueCollection();
myQueryStringCollection.Add("q", "HTML");
myWebClient.QueryString = myQueryStringCollection;
Console.WriteLine(myWebClient.QueryString);
}
}
The code above generates the following result.