Deep-copy an array

后端 未结 2 867
名媛妹妹
名媛妹妹 2020-12-21 06:15

I\'ve been banging my head against the wall on this one.
I know that if I create an Array in Powershell, then copy the array, it\'ll copy it as a reference type not a va

2条回答
  •  被撕碎了的回忆
    2020-12-21 06:42

    To copy an array, you can do the following:

    $c = (0,0,0)
    $d = $c | foreach { $_ }
    $c[0] = 1
    "c is [$c]"
    "d is [$d]"
    

    Result

    c is [1 0 0]
    d is [0 0 0]
    

    For your particular issue (comparing CPU usage of processes), something more specific would probably be better, as Keith pointed out.

提交回复
热议问题