Converting hashtable to array of strings

后端 未结 5 2213
一整个雨季
一整个雨季 2021-02-18 23:33

How can I convert a hashtable to an array of strings? Suppose $l_table is a hashtable. If I try

$l_array = $l_table | format-table

then $l_arra

5条回答
  •  没有蜡笔的小新
    2021-02-19 00:05

    The hash is just a Hashtable so it has a keys and a values property.

    $hash = @{}
    
    $hash["foo"] = "bob"
    
    $hash.Values
    
    $hash.Values | Out-string
    

    If you want to get the enumerator it will return you the keyvaluepair

    $hash.GetEnumerator() |%{$_ | out-string}
    

提交回复
热议问题