title: C# Equivalent of PHP http_build_query
body: <p>I need to pass some data to a PHP page on a server from my C# client using <code>HttpWebRequest</code>. The expected data according to the documentation is an array of arrays, something like this:</p>
  
  <pre><code>$postData = array(
      'label1' =&gt; 'myLabel',
      'label2' =&gt; array(
          'label2_1' =&gt; 3
          'label2_2' =&gt; array(
              'label2_2_1' =&gt; 3
          )
      )
  );
  </code></pre>
  
  <p>The structure above is just an example. It can be very complicated and the structure itself is not constant.</p>
  
  <p>In PHP there is a function named <code>http_build_query</code> which serializes these PHP nested arrays to a simple string, which can be sent as the data of a HTTP POST request. The problem is I need to call this PHP page from my C# application. I would like to represent these nested arrays either as nested <code>Dictionary&lt;string, object&gt;</code>s, or anonymous types.</p>
  
  <p>How can I do that? What rules does <code>http_build_query</code> follow to produce its output string?</p>
  
  <p>There is a very similar question <a href="https://stackoverflow.com/q/29833122/3899583">Converting PHP array of arrays to C#</a>, which does not solve my problem, unfortunately. The accepted answer recommends a solution for a fixed structure, the second one does not work at all.</p>