Hin*_*sum 4 powershell element hashtable
PS C:\Users\Hind> $b=@{}
PS C:\Users\Hind> $b+={k="a";v="b"}
A hash table can only be added to another hash table.
At line:1 char:1
+ $b+={k="a";v="b"}
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : AddHashTableToNonHashTable
Run Code Online (Sandbox Code Playgroud)
为什么失败了?如何成功地向哈希表添加一个元素?
更正,这失败了,因为您缺少@前面的字符@{k="a";b="b"}
PS C:\Users\Hind> $b=@{}
PS C:\Users\Hind> $b+= @ {k="a";v="b"}
@{}正在声明一个新的哈希表。{}是一个脚本块。她们不一样。