Iterate over all Query Values in C#
https://stackoverflow.com/questions/928203
Solution
If this question is about getting a querystring in ASP.NET, I think the link you are searching for is:
http://msdn.microsoft.com/en-us/library/system.web.httprequest.querystring.aspx
Essentially, Request.QueryString
gives you a collection that you can then iterate over.
OTHER TIPS
Using the Request.QueryString gives you a collection that you can iterate over. Using Request.QueryString.Allkeys allows you to iterate over a collection of strings that represent all of the keys i nthe query string. Using this we can come up with something like the below code in order to iterate over all keys and get their values.
foreach (string key in Request.QueryString.AllKeys)
{
Response.Write("Key: " + key + " Value: " + Request.QueryString[key]);
}
Hope this helped.
If the collection implements IEnumerable you can use a foreach, otherwise use a for loop with the .Length of the collection.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow