title: How can I get all Cookies of a CookieContainer?
body: <p>I want to export a CookieContainer to JSON using Newtonsoft.Json but unfortunately CookieContainer hasn't an enumerator or stuff, so I can't cycle through it ...</p>
  
  <p><strong>Edit:</strong> With my posted solution it would be something like this:</p>
  
  <pre><code>private static void Main(string[] args)
  {
      CookieContainer cookieContainer = new CookieContainer();
      cookieContainer.Add(new Cookie("name1", "value1", "/", ".testdomain1.com"));
      cookieContainer.Add(new Cookie("name2", "value1", "/path1/", ".testdomain1.com"));
      cookieContainer.Add(new Cookie("name2", "value1", "/path1/path2/", ".testdomain1.com"));
      cookieContainer.Add(new Cookie("name1", "value1", "/", ".testdomain2.com"));
      cookieContainer.Add(new Cookie("name2", "value1", "/path1/", ".testdomain2.com"));
      cookieContainer.Add(new Cookie("name2", "value1", "/path1/path2/", ".testdomain2.com"));
  
      CookieCollection cookies = GetAllCookies(cookieContainer);
  
      Console.WriteLine(JsonConvert.SerializeObject(cookies, Formatting.Indented));
      Console.Read();
  }
  </code></pre>