I'm trying to cast output from Get-Content myfile.txt into an ArrayList object so that I can easily insert and change strings with .add and .insert. What I've tried is
[Systems.Collections.ArrayList]mylist=@()
Get-Content myfile | $mylist # obviously wrong
Get-Content myfile | ForEach-Object {$mylist} # don't quite grasp the logic, get empty array as a result
Get-Content myfile | ForEach-Object {$mylist.Add()} # get overload error
if I just assign $mylist=Get-Content myfile.txt it will change data type to static array which I don't want
Get-Content myfile | ForEach-Object {$mylist.Add($_)}you need to actually pass a value toAddmethod?