A small library to help parse and manipulate querystring parameters in C#
If you're an ASP.NET developer then sooner or later you will come across an occasion when you want to manipulate or parse values from the current request's querystring (the querystring being the name/value pairs you often see appended to URLs).
The good news is that ASP.NET pages makes available the HttpRequest.QueryString property. The bad news is that this returns a read-only NameValueCollection that cannot be easily manipulated or even iterated over (you can't, for instance, use the foreach construct with a NameValueCollection). This means that parsing values in the querystring becomes a real chore.
To this end I developed a very small C# library (that can be found on GitHub) that enables developers to easily manipulate the querystring collection. It has useful methods to add, remove, replace, count and parse values within a querystring. Instead of outlining all the methods in detail I will show a small code excerpt below that uses the library to perform a few common tasks. If you're like me, you'll find this way is the best way to grasp how it works.