CookieContainer.Capacity 屬性


取得或設定 CookieContainer 可以保留的 Cookie 執行個體數目。Gets or sets the number of Cookie instances that a CookieContainer can hold.

 property int Capacity { int get(); };
public int Capacity { get; }
member this.Capacity : int
Public ReadOnly Property Capacity As Integer


Cookie 可以保留的 CookieContainer 執行個體數目。The number of Cookie instances that a CookieContainer can hold. 這是一種硬式限制且不可以利用加入 Cookie 的方式超過。This is a hard limit and cannot be exceeded by adding a Cookie.


Capacity 小於或等於零,或 (值小於 PerDomainCapacityPerDomainCapacity 不等於 MaxValue)。Capacity is less than or equal to zero or (value is less than PerDomainCapacity and PerDomainCapacity is not equal to MaxValue).


如果Count等於或超過Capacity,則會從Cookie容器中移除一或多個實例。If Count equals or exceeds Capacity, one or more Cookie instances are removed from the container. 已移除Count Capacity足夠的實例,如下所示:如果範圍內有Cookie過期的實例,則會清除它們。Enough instances are removed to bring Count below Capacity as follows: if there are expired Cookie instances in scope, they are cleaned up. 如果沒有,則會找到最近使用CookieCollection的最少,並從容器中移除。If not, then the least recently used CookieCollection is found and removed from the container.

Capacity 必須大於或等於 PerDomainCapacityCapacity must be greater than or equal to PerDomainCapacity.