This is a very simple question but I spent 2 hours Googling not a single one works.
$MyInList = New-Object System.Collections.Generic.List[string] $MyInlist.Add("sdf", "sdfsdf"); $MyInlist.Addrange(("sdf", "sdfsdf")); $MyInlist{"sdf", "sdfsdf"} $MyInlist.Add["sdf", "sdfsdf"]
$MyInlist
for($a=0; $a -le $MyInlist.Count; $a++){
Write-Output $MyInlist[$a]
}
I have tried all possible combination suggested by Google and mine own but none work. To display the content I have $MyInlist all by itself and the for loop they display nothing.
I dont know what I am doing wrong but both the initialize
and to display the contents nothing works. Please suggest a fix.