title: Manipulating QueryStrings in .NET
body: <p>I've seen multiple examples and answers on StackOverflow explaining that this would be the recommended way to create a QueryString to manipulate.</p>
  
  <pre><code>NameValueCollection test = HttpUtility.ParseQueryString(String.Empty);
  test.Add("hello", "world");
  Console.WriteLine(test.ToString());
  </code></pre>
  
  <p>But all it returns is</p>
  
  <pre><code>System.Collections.Specialized.NameValueCollection
  </code></pre>
  
  <p>What's going on? Simple .NET4 console application to test with (tried earlier Frameworks as well). If I don't feed it an empty string it starts working, but it seems odd that there are so many posts recommending this as a solution. Wrapped it in a try/catch statement as well just to see if anything strange was going on, no Exceptions are thrown. Am I really supposed to just give it a random string "a=b", then remove it from the NameValueCollection afterwards in order to get a usable HttpValueCollection?</p>
  
  <p>My ultimate goal was using this with an UriBuilder, grabbing the Query property from it and feeding it to ParseQueryString. However sometimes there might be no query string, UriBuilder.Query will return an empty string...thus this issue came up.</p>
  
  <p><strong>EDIT:</strong> In case anyone was confused, what I am intending for it to print out is the query string equivalent of the collection. So if I were to add another value to the collection</p>
  
  <pre><code>test.Add("other", "value");
  </code></pre>
  
  <p>The result of the ToString() method should be</p>
  
  <pre><code>"hello=world&amp;other=value"
  </code></pre>
  
  <p><strong>EDIT HI DAVE</strong>
  My claim? Why it doesn't work...
  <img src="https://i.stack.imgur.com/Tlphy.jpg" alt="enter image description here"></p>