Hash Tables
A hash table
is a data structure also known as a dictionary or associative array except
you store each value (object) using a key. It is associative type compact (key-value)
based data structure.
·
To
create an empty hash table.
$hash_Key_Val
= @{}
· Add value one by one
$key = 'Samsatya'
$value = 36
$hash_Key_Val[$key] = $value
· Add values in a loop
for($i = 0;$i -lt $Key.Count ; $i++)
{
$hash_Key_Val[$Key[$i]]
= $Val[$i];
}
· Check for the match in the value and return
corresponding key
foreach($value
in $List)
{
$CorrespKey
= ($hash_Key_Val.GetEnumerator() | ? {$_.Value -eq $value }).Name
}