Convert <Cookie> to CookieCollection in C #
Say I have List<Cookie>one and I want to convert it to CookieCollection. What is the easiest way to do this?
I know I can use the foreach loop, but there is no way to create it with code like this?
List<Cookie> l = ...;
var c = new CookieCollection() { l };
When I try to compile this, I get an error message:
The best overloaded Add method is 'System.Net.CookieCollection.Add (System.Net.CookieCollection)' for the collection initializer; some invalid arguments
btw, there are two methods Addthat supports CookieCollection:
public void Add(Cookie cookie);
public void Add(CookieCollection cookies);
+3
4 answers