Balaji Halekote
Balaji Halekote

Reputation: 1

How to create a nested dictionary?

Trying to create nested dictionary using object in powershell but showing error, so is there any way to create like below??

$Adress = New-Object "System.Collections.Generic.Dictionary[[String],[string,string]]

Upvotes: 0

Views: 389

Answers (1)

Mathias R. Jessen
Mathias R. Jessen

Reputation: 174690

[string,string] is not in itself a valid type literal. If the inner values should be dictionaries you need to specify Dictionary[string,string] as the second type constraint:

$nestedDict = [System.Collections.Generic.Dictionary[string,System.Collections.Generic.Dictionary[string,string]]]::new()

Upvotes: 2

Related Questions