I am trying to assign an array as a value to a dictionary entry as follows but its throwing exception.
$sd = New-Object 'System.Collections.Generic.SortedDictionary[int, string[]]'
$sd[0] = "Data1a", "asda";
Any idea?
Use cast to [string[]]:
$sd = New-Object 'System.Collections.Generic.SortedDictionary[int, string[]]'
$sd[0] = [string[]]("Data1a", "asda")
Another options is to change the dictionary value type to object[]:
$sd = New-Object 'System.Collections.Generic.SortedDictionary[int, object[]]'
$sd[0] = "Data1a", "asda"