Do I need to redefine Objects in Functions?
I have following main.ps1
$MyDict = New-Object 'system.collections.generic.dictionary[string,string]'
loadDict([ref]$MyDict)
and I have a functions.psm1 with the function
function loadDict([ref]$return)
{
#pseudo - load data from table
foreach ($TableRow in $LoadTable){
if($return.ContainsKey($TableRow.KEYID) -eq $false){
$return.Add($TableRow.KEYID, $TableRow.TEXT.Trim())
}
}
}
but I get the following Error..
[System.Management.Automation.PSReference'1[[System.Collections.Generic.Dictionary'2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]] "ContainsKey" Method not found
When I do not call the Function, but use the Function Code in Main, there is no Problem.
(corrected "[" typo)