I have a powershell script which uses Arraylist and the same syntax works for some data and sometimes it throws error for different data.
$parsed_teamarrlist = New-Object System.Collections.ArrayList
After adding data $parsed_teamarrlist
and writing to file , I try to clear the data in arraylist
if($parsed_teamarrlist) {
$parsed_teamarrlist.Clear()
}
During execution, for some data, it does not throws error, where as sometimes it throws the below error for different data.
Method invocation failed because [System.String] does not contain a method named 'Clear'.
+ $parsed_teamarrlist.Clear()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound