有没有办法在 vb.net 的每个循环中循环多个变量? [英] Is there a way to loop over multiple variables in a for each loop in vb.net?
本文介绍了有没有办法在 vb.net 的每个循环中循环多个变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想遍历两个字符串数组但不起作用.可能看起来像下面这样:
I would like to loop over two string arrays but does not work. Would probably look something like the following:
For Each (s1, s2) As (String, String) In (stringArray1, stringArray2)
是否有类似于 python 元组的东西可以使用?
Is there something similar to python tuples that I could use?
推荐答案
我认为 vb.net 不支持这种方式.
I think that vb.net don't support this in this way.
如果你有两个 IEnumerables,你可以这样做
If you have two IEnumerables, you can do something like this
Using lst1 As IEnumerator(Of X) = List1.GetEnumerator(),
lst2 As IEnumerator(Of Y) = List2.GetEnumerator()
While lst1 .MoveNext() AndAlso lst2 .MoveNext()
If lst1 .Current.Equals(lst2 .Current) Then
''Put here your code.
End If
End While
End Using
要获得更好的解释,请查看此相关链接:是否可以同时遍历两个 IEnumerable 对象?
For a better explanation, check this related link: Is it possible to iterate over two IEnumerable objects at the same time?
这篇关于有没有办法在 vb.net 的每个循环中循环多个变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文