在VB.NET中清理2维数组

时间:2012-04-26 17:19:48

标签: windows vb.net arrays

我声明我的多维数组如下:

Dim invoice_discountitems(100, 1) As String

我用这个填充我的数组:

'Fill Array with items discounts
                        For i As Int16 = 0 To data_set.Tables("discount_items").Rows.Count - 1
                            invoice_discountitems(i, 0) = data_set.Tables("discount_items").Rows(i).Item("item_code")
                            invoice_discountitems(i, 1) = data_set.Tables("discount_items").Rows(i).Item("discountitem_average")
                        Next

现在我如何删除此数组的已填充项? 在此先感谢

1 个答案:

答案 0 :(得分:2)

因为数组是静态大小的,所以空数组与刚刚初始化的数组相同。所以,如果你想清除整个事情:

invoice_discountitems = New String(100, 1)

或者,如果您希望to clear specific elements, use Array.Clear()

Array.Clear(invoice_discountitems, 1, 10)