Does powershell have associative arrays?

前端 未结 8 778
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-16 09:25

I am writing a function that returns an id, name pair.

I would like to do something like

$a = get-name-id-pair()
$a.Id
$a.Name

like

8条回答
  •  感动是毒
    2020-12-16 10:06

    Will add also the way to iterate through hashtable, as I was looking for the solution and did not found one...

    $c = @{"1"="one";"2"="two"} 
    foreach($g in $c.Keys){write-host $c[$g]} #where key = $g and value = $c[$g]
    

提交回复
热议问题