Question

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))
Was it helpful?

Solution

Just add {} after the array.

myDict.Add(177, New String(24){})
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top