Skip to content

Instantly share code, notes, and snippets.

@ScriptingPro
Created January 5, 2018 05:12
Show Gist options
  • Save ScriptingPro/2d9f75a8d144bb08878f226620c49ed4 to your computer and use it in GitHub Desktop.
Save ScriptingPro/2d9f75a8d144bb08878f226620c49ed4 to your computer and use it in GitHub Desktop.
Playing with Collections
$SplitHereString = @"
a
b
c
"@ -split [System.Environment]::NewLine
$SplitHereString.GetType() # notice it's String[] / System.Array
$ConstructedArray = @('a','b','c')
$ConstructedArray.GetType() # notice it's Object[] / System.Array
$TypecastedConstructedArray = [string[]]@('a','b','c')
$TypecastedConstructedArray.GetType() # notice it's String[] / System.Array
$SplitNumberHereString = @"
1
2
3
"@ -split [System.Environment]::NewLine
$SplitNumberHereString.GetType() # notice it's String[] / System.Array
[int[]]$TypecastedSplitNumberHereString = @"
1
2
3
"@ -split [System.Environment]::NewLine
$TypecastedSplitNumberHereString.GetType() # notice it's Int32[] / System.Array
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment