CookieContainer.Capacity 属性

定义

获取或设置可以保存的 Cookie 实例 CookieContainer 数。

public:
 property int Capacity { int get(); void set(int value); };
public:
 property int Capacity { int get(); };
public int Capacity { get; set; }
public int Capacity { get; }
member this.Capacity : int with get, set
member this.Capacity : int
Public Property Capacity As Integer
Public ReadOnly Property Capacity As Integer

属性值

可以保存的 Cookie 实例 CookieContainer 数。 这是一个硬限制,不能通过添加 a Cookie.

例外

要设置的容量小于或等于零或(值小于 PerDomainCapacityPerDomainCapacity 不等于 Int32.MaxValue)。

注解

如果 Count 等于或超过 Capacity,则会从容器中删除一个或多个 Cookie 实例。 删除了足够的实例,以便CountCapacity如下所示:如果作用域中有过期Cookie的实例,则会清理这些实例。 如果没有,则会从容器中找到并删除最近使用最少的 CookieCollection 容器。

Capacity 必须大于或等于 PerDomainCapacity

适用于

另请参阅