如何从2D数组中获取值? [英] How to get values out of a 2D array?

查看:73
本文介绍了如何从2D数组中获取值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用2D数组获取字段中值的列数.但是,由于该数组位于嵌套循环内,因此我不知道如何检索存储在该数组aryRow中的值.当我在循环外重复使用它时,会弹出一条消息 向上说aryRow没有被声明.您知道一种解决方法吗?

I can use 2D array to get the column count of values in a field. However, since this array is INSIDE the nested loop, I don't know how to retrieve values stored in this array, aryRow. When I re-use it outside the loop, a message popping up say aryRow isn't declared. Do you know a way to work around it?

For n As Integer = 0 To dt.Rows.Count-1                                       
Dim ary() As String = dt.Rows(n).Item(i).ToString.Split(";")  
Dim aryRow(ary.Lenght - 1, 3) As Integer

   For j As Integer = 0 To ary.Length - 1
       Dim k As Integer = (Val(ary(j)))
       aryRow(j, k - 1) += 1
   Next
Next

将aryGetValue(,)转换为整数= aryRow(j,k) ->弹出一条错误消息.

Dim aryGetValue( , ) as integer = aryRow(j,k)  -> pops up an errow message.

推荐答案

是的,要以一种好的方式进行此操作有点困难.您知道数组是不可变的,就像代码中的代码一样,它是一个消耗内存的野兽.

Yea a little bit difficult to do this on a good way. An array is immutable you know and a memory consuming beast like it is in your code.

但是您的目标是什么,我看到一些有关在数据库或excel表中包含用分号分隔的字符串的项目的信息.

But what is your goal, I see something about items which contain a with semicolons splitted strings inside database or excel tables.


这篇关于如何从2D数组中获取值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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