Add(Key: String, Value: String);
Key. Element key in collection.
Value. Value of element in collection.
The Add method adds a new element into the collection.
To remove an element from collection by its key, use the IVZItemsNames.Remove method.
To execute the example, add a link to the Visualizators system assembly.
Sub UserProc;
Var
Names: IVZItemsNames;
Item: String;
Key: Variant;
Begin
Names := New VZItemsNames.Create;
Names.Add("14", "Belgorodskaya oblast");
Names.Add("15", "Bryanskaya oblast");
Names.Add("17", "Vladimirskaya oblast");
Debug.WriteLine("Original amount of elements in collection: " +
Names.Count.ToString);
// Get first collection element
Key := Names.AllKeys.Item(0);
Item := Names.Item(Key);
Debug.WriteLine("First element" + Key + " " + Item);
// Remove this element
Names.Remove(Key);
Debug.WriteLine("Collection size after element is removed «" + Item + "»: " +
Names.Count.ToString);
// Clear entire collection
Names.Clear;
End Sub UserProc;
After executing the example a collection of three elements is created. Then one of the elements is removed form the collection. The console window displays collection size after its creation and after one element removal:
Original amount of collection elements: 3
Collection size after the "Belgorodskaya oblast" element is removed: 2
After executing all the operation the collection is cleared.
See also: