Is it possible to iterate over two IEnumerable objects at the same time?

前端 未结 7 1944
醉梦人生
醉梦人生 2020-12-19 12:55

If I have a List(Of x) and a List(Of y) is it possible to iterate over both at the same time?

Something like

for each _x as X, _y as Y in List(of x         


        
7条回答
  •  爱一瞬间的悲伤
    2020-12-19 13:29

    You mean without doing a nested loop?

    foreach _x as X in List(of x)
         foreach _y as Y in List(of y)
              if _x.item = _y.item then
                   'do something
              end if
     next
    

    Not a VB programmer so my syntax might be wrong but you get the idea.

提交回复
热议问题