我实际上是在尝试创建一个配对列表,但事实证明这非常困难
在有人提到 Hashtables 之前请注意,会有我不关心的重复项。
例如,如果我这样做
$b = @{"dog" = "cat"}
我明白了
Name Value ---- ----- dog cat
which is good. However, I'm then unable to add the likes of
$b += @{"dog" = "horse"}
Item has already been added. Key in dictionary: 'dog' Key being added: 'dog'
我只是想创建一个数据表我可以添加到使用类似.Add()
或+=
.
最佳答案
我相信哈希表列表应该可以完成您所追求的。
$ht = @{foo='bar'}
$list = [System.Collections.Generic.List[hashtable]]::new()
$list.Add($ht)
$list.Add($ht)
$list.Add($ht)
$list
关于arrays - 元组/数组对列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54373785/