Jonathan Edgardo
Jonathan Edgardo

Reputation: 513

Clean 2 Dimentional Array in VB.NET

I declared my multidimentional array like this:

Dim invoice_discountitems(100, 1) As String

I Fill my array with this:

'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

Now how i can remove the filled items of this array? Thanks in Advance

Upvotes: 0

Views: 111

Answers (1)

Jason
Jason

Reputation: 907

Because an array is statically sized, an empty array is the same as a freshly initialized array. So, if you want to clear the whole thing:

invoice_discountitems = New String(100, 1)

Or, if you wish to clear specific elements, use Array.Clear()

Array.Clear(invoice_discountitems, 1, 10)

Upvotes: 2

Related Questions