Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27337

lambda expresions with list.foreach methods

$
0
0
Hi

lets say i had 2 list(of class1) objects

and wanted to iterate through them checking for something with a for each loop, i always have a problem keeping the code simple because i have to iterate through one then make otherloops and it all gets messy quickly.

im trying to do something like this

Code:

for each item in list1

        if list2.foreach(function(i)
                      'then something like'
                      if i.name = item.name
                      return false
                      end function) then

                      do some other code
        end if
next

so here ill have 1 outerloop, then use the method fornext related to list class to do an innerloop, to compare variables within each class.
how do i actually achieve something like this, i just cant make it work, and it looks so much tidier then nested loops etc
i cant find any good help with this
or
is there another way to do it?

Viewing all articles
Browse latest Browse all 27337

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>