数组的DirectCast [英] DirectCast of array

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

问题描述

我有100个数组(Columns1,Columns2,Columns3 .... Columns100),其中"Columns"之后的数字是可变的.
我必须为每个数组做同样的事情,再做100次.
有没有一种方法可以使我的代码(=需要为每个数组运行的代码)循环,在其中可以使数组变量的名称变为类似这样的内容:

I Have 100 arrays (Columns1, Columns2, Columns3.... Columns100) where the number after "Columns" is variable.
I have for each array to do the same thing, 100 times again.
Is there a way that I can make a loop around my code (= the code that needs to run for each array) where i can make the name of the array variable, something like this:

i = 1
Do until i = 100
    'with "Columns" & i
    '...some code
    'end with
Next



目的是我可以在几行中进行编码,而不是将代码复制100次并改写数组的名称.

提前谢谢!
Kevin



The purpose is that i can do my coding in a few lines, instead of copying the code 100 times and adapt the name of the arrays.

Thanks in advance!
Kevin

推荐答案

您可以使用如下数组:
You can use a array like this:
Dim Columns As Object()() = New Object(100 - 1)() {}
For i As Integer = 0 To 99
                ' now the current array is Columns(i)
		' now you can set the value of Columns(i)(...)
	Columns(i)(0) = "object1"
Next


这篇关于数组的DirectCast的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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