1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
[string[]]$T=@( "A","b", "c", "d", "e", "f", "g", "x",'a')
[string[]]$T2=@( "b", "d", "e", "f", "gg", "h",'y','y')
$CaseInsensitive=[System.Collections.Generic.HashSet[String]]::new($T,[StringComparer]::InvariantCultureIgnoreCase)
$CaseInsensitive.ExceptWith($T2)
$CaseInsensitive
#A c g x
$CaseInsensitive=[System.Collections.Generic.HashSet[String]]::new($T2,[StringComparer]::InvariantCultureIgnoreCase)
$CaseInsensitive.ExceptWith($T)
$CaseInsensitive
#gg h y
$a1 = "A","b", "c", "d", "e", "f", "g", "x",'a'
$a2 = "b", "d", "e", "f", "gg", "h",'y','y'
$b1 = $a1 | Where-Object {$a2 -notcontains $_}
$b2 = $a2 | ? {$a1 -notcontains $_}
$b1
#A c g x a
$b2
#gg h y y |
Partager