SysDragon
SysDragon

Reputation: 9888

Passing a new empty array as a parameter

I have a Dictionary(Of Integer, String()). When I add a new Key I want to add an empty array with a defined length to it, so I can add and use the values later on.

Dim myDict As New Dictionary(Of Integer, String())()
Dim auxData(24) As String

myDict.Add(177, auxData)

Is there any way to add a value to the Dictionary without need to use a variable to use in the value? Just declaring an empty string array directly, with a specified length.

Something like:

myDict.Add(177, New String(24))

Upvotes: 0

Views: 1696

Answers (1)

Magnus
Magnus

Reputation: 46929

Just add {} after the array.

myDict.Add(177, New String(24){})

Upvotes: 3

Related Questions