John
John

Reputation: 223

Clear part of the data from a two-dimension integer array

If my array is A(i,j) can I use Array.Clear to zero all of the elements for i=2, for example. It does not work as I expected.

Upvotes: 0

Views: 797

Answers (1)

John Wigger
John Wigger

Reputation: 904

Take a look at this example. If I want to initialize all the elements for the second row (index = 1) I specify the starting position in the array ordered by row ascending, column ascending and the number of records to clear as the number of columns in your array.

Dim arr(,) As Integer = {{1, 2, 3}, {4, 5, 6}}
        Array.Clear(arr, 1 * 3, 3)

Clearing the entire array would be

Array.Clear(arr,0,6)

Upvotes: 1

Related Questions