清除二维整数数组中的部分数据 [英] Clear part of the data from a two-dimension integer array

查看:38
本文介绍了清除二维整数数组中的部分数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,如果我的数组是 A(i,j),我可以使用 Array.Clear 将 i=2 的所有元素归零.它不像我预期的那样工作.

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)

清除整个数组是

Array.Clear(arr,0,6)

这篇关于清除二维整数数组中的部分数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆