System.Generics.Collections.TDictionary.TryAdd
Delphi
function TryAdd(const Key: TKey; const Value: TValue): Boolean;
C++
bool __fastcall TryAdd(const TKey Key, const TValue Value);
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
function | public | System.Generics.Collections.pas System.Generics.Collections.hpp |
System.Generics.Collections | TDictionary |
Description
Add key-value pair when key does not exist.
TryAdd adds a key-value pair to a dictionary when the key does not exist. 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 exits with False. Otherwise, it is equivalent to Add (key, value) and returns True.
See Also
Code Examples