System.Generics.Collections.TDictionary.Add
Delphi
procedure Add(const Key: TKey; const Value: TValue);
C++
void __fastcall Add(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.
Add adds a key and its corresponding value to the dictionary. Both the key and the value can be nil.
If the key already exists in the dictionary, an exception is thrown.
An OnKeyNotify event and an OnValueNotify event occur indicating that an entry was added to the dictionary.
The Items property lists all dictionary entries. You can also set and get values by indexing directly the Items property. For instance, you can set a value this way:
Items[key] := value;
Setting the value this way overwrites the value for an existing key, but does not raise an exception.
See Also
Code Examples