title: Adding Http headers from string in C#
body: <p>I've got some C# method which gets JSON data from Uri specified by user. User also can add some extra headers - my method gets them as a string (separated by new line '\n'). If it's single header there is no problem. But what if user wants to add few headers? I'm using WebClient class.</p>
  
  <p>Piece of method:</p>
  
  <pre><code>using (WebClient web = new WebClient())
              {
                  switch (Method.ToUpper())
                  {
                      case "GET":
                          {
                              web.Headers.Add(UserHeaders);
                              result = web.DownloadString(UserUri);
                              break;
                          }
                  }
  </code></pre>
  
  <p>If header is like below there is no problem:</p>
  
  <pre><code>Content-Type: application/json
  </code></pre>
  
  <p>But how to add few headers - in example:</p>
  
  <pre><code>Content-Type: application/json
  Accept-Language: en-US
  Accept-Charset: utf-8
  </code></pre>