System.Generics.Collections.TDictionary.Add

From Appmethod Libraries
Jump to: navigation, search

Object Pascal

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. The key cannot be nil, but the value can.

If the key already exists in the dictionary, an exception is thrown.

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

The Items property lists all dictionary entries. You can also set and get values by indexing the Items property directly. 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