C#:VB.NET:如何从这个锯齿状的字符串数组中提取值

时间:2011-03-16 15:18:36

标签: vb.net multidimensional-array

Dim strTest(recordSet.Count)() As String

While index < recordSet.Count
   strTest(index)(recordset.item(index).getvalue(0).tostring,
                  recordset.item(index).getvalue(0).tostring,
                  recordset.item(index).getvalue(0).tostring)
   index +=1
End While

然后,一旦上面填充了数组,我需要找到第二个paren的第二个维度中包含的另一个变量是否包含我的变量的值。

if strTest.Contains(someVariable) then
   extract the index and get the other two values in the array
end if

所以基本上我是如何在这里执行第二段代码的。

2 个答案:

答案 0 :(得分:1)

For Each set As String() in strtest
   If set(1).Equals(someVariable) Then
     'Get set(0) and set(2)
   End If
Next

循环通过数组拉动项目作为数组并检查中间项目。我认为这就是你的问题所在。

答案 1 :(得分:0)

也许你可以使用strTest.IndexOf()?