传递一个新的空数组作为参数

时间:2013-09-04 09:48:39

标签: arrays vb.net .net-2.0

我有Dictionary(Of Integer, String())。当我添加一个新Key时,我想添加一个定义了长度的空数组,所以我可以稍后添加和使用这些值。

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

myDict.Add(177, auxData)

有没有办法在Dictionary中添加值而无需在值中使用变量?只是直接声明一个空字符串数组,具有指定的长度。

类似的东西:

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

1 个答案:

答案 0 :(得分:3)

只需在数组后添加{}

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