public void Add(
TKey key,
TValue value
)
Public Sub Add (
key As TKey,
value As TValue
)
public:
virtual void Add(
TKey key,
TValue value
) sealed
abstract Add :
key : 'TKey *
value : 'TValue -> unit
override Add :
key : 'TKey *
value : 'TValue -> unit
You need to call this method only when this CacheTKey, TValue instance was initialized without using an item loader. Otherwise, you need only to read the get accessor of the indexer property, which automatically invokes the item loader to add new items.
If the key of element already exists in the cache, this method throws an exception. In contrast, using the setter of the indexer property replaces the old value with the new one.
If you want to renew an element in the evaluation order, use the Touch method.
If EnsureCapacity is this method approaches an O(1) operation. Otherwise, when the capacity of the inner storage must be increased to accommodate the new element, this method becomes an O(n) operation, where n is Count.
ArgumentNullException | key is . |
ArgumentException | key already exists in the cache. |