How to Initialize Argument: Dictionary<String,String[]>

Hey all,
I am having some trouble initialize an argument that is a Dictionary that contains a String and a StringArray.

I assumed New Dictionary (String,String) would of worked but it’s not.

Just wondering if any one could help shed some light on this.

Thanks for your help :slight_smile:

The proper syntax is

New Dictionary(of string, string)

You left out the of.

2 Likes

Thanks for the quick reply!

However i forgot it i n the post, but not in my code. That is still not working.

I’m sure i’m missing something very simple like that.
:slight_smile:

New Dictionary(Of String, String())

Dirty hack/trick: if you don’t know the datatype, just dump in whatever and read carefully the error

image

1 Like

Wow, that’s amazing!

That seems to have worked perfectly!
I’ve been here for 20 mins trying to fix that and you did it in less than 6 :slight_smile:

If it’s not too much trouble can you explain what the difference was between the two post? Just I can learn from this.

My original code contained an “of”, i just missed when i posted (and wasn’t aware of the lack of editing) so i don’t believe it was just that.

In vb.net you declare an array of strings like this, not with square brackets

Dim myArray() As String

In the declaration you needed Of Type, Type, and the type array of strings is String()
Also take a look at the snapshot above. It will be easier if you read the errors.

That’s weird because when you choose Array of String through the variable definition screens, where you select from the popup, it displays it as String[] not String ().

image

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.