System.Generics.Collections.TDictionary.AddOrSetValue

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

procedure AddOrSetValue(const Key: TKey; const Value: TValue);

C++

void __fastcall AddOrSetValue(const TKey Key, const TValue Value);

Properties

Type Visibility Source Unit Parent
procedure
function
public
System.Generics.Collections.pas
System.Generics.Collections.hpp
System.Generics.Collections TDictionary

Description

Add key-value pair even when key already exists.

AddOrSetValue adds a key-value pair to a dictionary even if the key already exists. The key cannot be nil, but the value can. This method checks to see if the key exists in the dictionary, and if it does, it is equivalent to Items[key] := value;. Otherwise it is equivalent to Add(key, value);.

An OnKeyNotify event and an OnValueNotify event occur indicating an entry was added to the dictionary.

See Also

Code Examples