Let's say I have List<Cookie>
and I want to convert it to a CookieCollection
. What's the easiest way to do this?
I know I can use a foreach loop, but isn't there a way to instantiate it with code similar to this?
List<Cookie> l = ...;
var c = new CookieCollection() { l };
When I try to compile that though, I get the error:
The best overloaded Add method 'System.Net.CookieCollection.Add(System.Net.CookieCollection)' for the collection initializer has some invalid arguments
btw, there are two Add
methods that CookieCollection
supports:
public void Add(Cookie cookie);
public void Add(CookieCollection cookies);