How to decide which of the following to use in a program. https://gist.github.com/kevinblumenfeld/4a698dbc90272a336ed9367b11d91f1c
- Arrays
- ArrayList
- List
- HashTable
- Dictionary
- HashSet
- LinkList
- Queue
- Stack
- SortedSet
- SortedDictionary
.Net System.Collections.Generic Namespaces:
https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic?view=net-8.0
How use .Net namespaces in PowerShell.
# List: https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1?view=net-8.0
$StringList = [System.Collections.Generic.List[string]::new()
# SortedList https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.sortedset-1?view=net-8.0
$SortedIntSet = [System.Collections.Generic.SortedSet[int]::new()
# Generic objects
$CustomObjects = [System.Collections.Generic.List[PSObject]]::new()
Or include the whole .Generic namespace one time at the beginning of the script. Then just use the class name instead of the full namespace.
using namespace System.Collections.Generic