gpt4 book ai didi

arrays - 向 ArrayList 添加一组新值

转载 作者:可可西里 更新时间:2023-11-01 11:11:30 25 4
gpt4 key购买 nike

所以我将以下 ArrayList 存储在 $var 中:

ip_prefix   region         string   0.0.0.0/24  GLOBAL         Something0.0.0.0/24  GLOBAL         Something0.0.0.0/24  GLOBAL         Something0.0.0.0/24  GLOBAL         Something

I need to add a row to this however the following code returns an error:

$var.add("127.0.0.1/32", "GLOBAL", "something")

错误:

Cannot find an overload for "Add" and the argument count: "3".At line:1 char:1+ $awsips.add("127.0.0.1/32", "GLOBAL", "SOMETHING")+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    + CategoryInfo          : NotSpecified: (:) [], MethodException    + FullyQualifiedErrorId : MethodCountCouldNotFindBest

我确信这是我必须调整的简单事情,但是 Google 搜索让我原地踏步。

最佳答案

$var = New-Object System.Collections.ArrayList
$var.Add(@{"ip_prefix" = "0.0.0.0/24"; "region" = "GLOBAL"; string = "Something"})
$var.Add(@{"ip_prefix" = "127.0.0.1/32"; "region" = "GLOBAL"; string = "SOMETHING"})

$var
$var | %{ Write-Output "$($_.ip_prefix), $($_.region), $($_.string)" }

或者:

$var = @()
$var += @{"ip_prefix" = "0.0.0.0/24"; "region" = "GLOBAL"; string = "Something"}
$var += @{"ip_prefix" = "127.0.0.1/32"; "region" = "GLOBAL"; string = "SOMETHING"}

关于arrays - 向 ArrayList 添加一组新值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45459154/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com