質問

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))
役に立ちましたか?

解決

Just add {} after the array.

myDict.Add(177, New String(24){})
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top