I have an object which is of type {system.collections.arraylist]
To add a single element I can use the Add method but to add an array I have to use the ‘+=’ method.
Does anyone have a technical explanation for this as ‘+=’ doesnt seem to be in the microsoft doco below:
I am also assuming that ‘+=’ does not destroy and rebuild the arraylist everytime an array is added?
I expect $al.count to have a value of 2 but it has one. And if you try and export-csv on $al you get junk.
However instead of $al.add($adds) I do $al += $adds its all fine.
So my concern was do I lose the benefit of arraylists in not destroying/creating a new array every time i ‘+=’ into it?
And just curious - why shouldnt one use arraylists any more? There is something better? btw Im stuck with PS 5.1 if the new thing is version 6 or 7.
Thanks. Ill have a look at that class.
Also found this class - system.collections.generic.hashset. Never heard of it. Is it like @{}?
My logic is something like this:
Initialise my output array.
Run through a loop.
on each loop initialise an internal array and populate it.
At the end of each loop iteration check a criteria to determine whether the internal array is added to the output array.
at the vey end of the script export-csv the output array.