vb.net - How to loop through two lists simultaneously? -


i have referred following question at: using foreach loop iterate through 2 lists. question this, regards chosen answer: can o.dosomething comparison? in:

for each in lista.concat(listb)     if(a lista=a listb)         here     end if next 

as might've guessed, i'm using vb.net , know how can have shown here. iterate through joined list separately/independently. thanks!

your question indicates need join operation, because it's not want iterate on 2 lists, want match items 1 list other.

    dim joinedlists = item1 in list1 _                     join item2 in list2 _                     on item1.bar equals item2.bar _                     select new {item1, item2}      each pair in joinedlists         'do work on combined item here'         'pair.item1'         'pair.item2'     next 

other answers recommend zip. function takes 2 sequences , produces single result, join, geared work in fifo method on both lists. if need connections made based on equality, join built right tool job.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -