February 2019
Intermediate to advanced
626 pages
15h 51m
English
Elements may be explicitly added to a hashtable using the Add method:
$hashtable = @{}
$hashtable.Add("Key1", "Value1")
If the value already exists, using Add will generate an error (as shown here):
PS> $hashtable = @{"Existing", "Value0"}PS> $hashtable.Add("Existing", "Value1")Exception calling "Add" with "2" argument(s): "Item has already been added. Key in dictionary: 'Existing' Key being added: 'Existing'"At line:2 char:1+ $hashtable.Add("Existing", "Value1")+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : ArgumentException
The Contains method will return true or false, depending on whether or not a key is present ...
Read now
Unlock full access