Prevent ArrayList.Add() from returning the index

前端 未结 2 1110
野趣味
野趣味 2020-12-08 06:21

is there a way to supress the return value (=Index) of an ArrayList in Powershell (using System.Collections.ArrayList) or should I use another class?

$myArray         


        
2条回答
  •  执笔经年
    2020-12-08 07:07

    Two more options :)

    Pipe to out-null

    $myArrayList.Add("test") | Out-Null  
    

    Assign the result to $null:

    $null = $myArrayList.Add("test")
    

提交回复
热议问题