Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@techthoughts2
Last active December 27, 2022 04:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save techthoughts2/fd284787eee122e8c50fd21fc6b1ea29 to your computer and use it in GitHub Desktop.
Save techthoughts2/fd284787eee122e8c50fd21fc6b1ea29 to your computer and use it in GitHub Desktop.
# use generic list to add objects in a performant way
$starTrekShowInfo = New-Object System.Collections.Generic.List[string]
$starTrekShowInfo.Add('Star Trek: The Next Generation')
# use custom objects for high performance adds of custom object
$choiceArray = New-Object System.Collections.Generic.List[PSCustomObject]
#------------------------------------------------------------------------------
# old method which should no longer be used IAW:
# https://docs.microsoft.com/en-us/dotnet/api/system.collections.arraylist?view=net-6.0
# adding stuff to emtpy array objects quickly
$myarray = [System.Collections.ArrayList]::new()
[void]$myArray.Add('Value')
#------------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment