Method TrimExcess
TrimExcess(bool)
Sets the key/value list pair capacity of this dictionary to what it would be if it had been originally initialized with all its entries, and optionally sets the capacity of each value list to the actual number of values in the list.
Declaration
public void TrimExcess(bool trimValueLists = true)
Parameters
Type | Name | Description |
---|---|---|
bool | trimValueLists | true to trim all the value lists as well, or false to only trim the dictionary. |
TrimExcess(int, bool)
Sets the key/value list pair capacity of this dictionary to hold up a specified number of entries without any further expansion of its backing storage, and optionally trims the capacity of each value list to the actual number of values in the list.
Declaration
public void TrimExcess(int dictionaryCapacity, bool trimValueLists = true)
Parameters
Type | Name | Description |
---|---|---|
int | dictionaryCapacity | The new key/value list pair capacity. |
bool | trimValueLists | true to trim all the value lists as well, or false to only trim the dictionary. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Capacity specified is less than the number of entries in the dictionary. |