- 追加された行はこの色です。
- 削除された行はこの色です。
#author("2021-12-13T23:43:11+00:00","default:admin","admin")
#author("2021-12-20T07:14:44+00:00","default:admin","admin")
*配列 [#q2798542]
-[[PowerShellの配列とは?基本的な使い方と各種の操作を解説:https://www.fenet.jp/infla/column/technology/powershell%E3%81%AE%E9%85%8D%E5%88%97/]]
-[[そろそろ PowerShell の一次配列の罠と回避について一言いっておくか:https://tech.guitarrapc.com/entry/2015/09/05/012733]]
-[[配列の宣言・初期化・代入・参照 (PowerShell プログラミング):https://www.ipentec.com/document/powershell-array]]
-[[空の固定長配列を作成するには?:https://winscript.jp/powershell/43]]
*連想配列 [#n7f18160]
-[[foreach で連想配列(ハッシュ)の全ての要素を処理する方法:https://bayashita.com/p/entry/show/200]]
*Set [#t4cb9566]
$set = New-Object System.Collections.Generic.HashSet[object]
$set.Add($someObject) # $someObjectを追加
:
$set.ExceptWith($exceptSet) # $exceptSet に含まれる要素と同じ要素を削除
*List [#q1146eae]
-[[PowerShell で System.Collection.Generics.List を扱ってみる:https://tech.guitarrapc.com/entry/2013/09/22/122454]]
-[[[PowerShell Core 入門] 動的配列の使用方法:https://blog.powershell-from.jp/?p=2385]]
$list = New-Object System.Collections.Generic.List[string]
$list.Add("a")
$list.Add("b");
$list.Add("c");
$list.Add("d");
$list.Add("e");
$list.Add("a")
$list.Add("a")
$list.Add("a")
$list.AddRange( [string[]]@("e","f","g","h") ) # make sure type match for list
$list.Find({$args -eq "a"}) # return a
$list.Find({$args -ceq "A"}) # nothing return
$list.FindLast({$args[0] -eq "c"})
$list.FindAll({$args[0] -eq "a"}) # find all a
$list | where {$_ -eq "a"}
$list.FindIndex(0,{$args[0] -eq "a"}) # retrun index 0
$list.FindIndex(1,{$args[0] -eq "a"}) # retrun index 5
$list.Remove("a") # delete first a # Remove method for first match item
$list.RemoveAll("a")
$list.RemoveAt(0)
$list.Contains("f") #true
$list.Contains("a") #false
$stringarray = $list.ToArray()
$list.Clear()