3
是否有一個函數,方法或語言結構允許從Powershell中的多維數組中檢索單個列?Powershell:如何從多維數組中獲取單個列?
$my_array = @()
$my_array += ,@(1,2,3)
$my_array += ,@(4,5,6)
$my_array += ,@(7,8,9)
# I currently use that, and I want to find a better way:
foreach ($line in $my_array) {
[array]$single_column += $line[1] # fetch column 1
}
# now $single_column contains only 2 and 5 and 8
我的最終目標是從一列中找到非重複的值。
謝謝!在看到您提交之前,我剛剛找到了相同的解決方案。對於第二部分...呃...我試圖找到一個更好的:) –
在PowerShell中總是有很少的方法去皮膚貓。 :) – BartekB