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

大憨熊 提交于 2020-01-07 03:49:09

问题


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.


回答1:


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)


来源:https://stackoverflow.com/questions/4888312/clear-part-of-the-data-from-a-two-dimension-integer-array

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!