System.Collections.Hashtable object stores key/value pairs. In other programming languages, such objects are also referred to as dictionaries or associative arrays. System.Collections.Hashtable derives directly from System.Object and implements System.IClonable and IDictionary. System.Collections namespaces, there is no counterpart with the name System.Collections.Generic.Hashtable<TKey, TValue>. However, there is a System.Collections.Generic.Dictionary<TKey, TValue> class. Dictionary<TKey, TValue> class. PS: C:\> $ht = @{
key_1 = 'foo'
key_2 = 'bar'
key_3 = 'baz'
}
PS: C:\> $ht.GetType().FullName
System.Collections.Hashtable
PS: C:\> $ht.key_4 = 'added'
keys (whose type is System.Collections.Hashtable+KeyCollection which implements System.Collections.ICollection and System.Collections.IEnumerable) provides the names of the keys in the hashtable. This allows to iterate over the key/value pairs: $ht.keys | foreach-object { "$_ -> $($ht[$_])" }
GetEnumerator() returns a an enumerator that provides System.Collections.DictionaryEntry objects with the two properties Key (apparently aliased to Name in PowerShell) and Value: $ht.GetEnumerator() | foreach-object { "$($_.key) -> $($_.value)" }