Comment créer un tableau de tableaux dans PowerShell?
Je veux créer un tableau de tableaux en powershell.
$x = @(
@(1,2,3),
@(4,5,6)
)
Fonctionne très bien. Cependant, parfois, j'ai un tableau dans le tableau de la liste. Dans cette situation, powershell ignore l'une des listes:
$x = @(
@(1,2,3)
)
$x[0][0] # Should return 1
Unable to index into an object of type System.Int32.
At line:1 char:7
+ $a[0][ <<<< 0]
+ CategoryInfo : InvalidOperation: (0:Int32) [], RuntimeException
+ FullyQualifiedErrorId : CannotIndex
Comment puis-je créer un tableau de tableaux, la garantie c'est de rester comme un deux-dimension tableau, même si le tableau n'a qu'un seul élément de tableau?
source d'informationauteur iTayb
Vous devez vous connecter pour publier un commentaire.
En ajoutant une virgule à la force pour créer un tableau:
Manière Simple: