Quantcast
Channel: Visual COBOL - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 4356

RE: Lambda expression and Linq

$
0
0

This should work, but I think the delegate for the Where method needs to return a boolean (condition-value in COBOL), so something like this:

     $set ilusing"System.Collections.Generic"

     $set ilref"System.Core"

      01 myList type List[string].

      01 myList2 type IEnumerable[string].

          invoke myList::ForEach(

              delegate (x as string)

                  display x

              end-delegate)

          set myList2 to myList::Where(delegate using x as string returning y as condition-value

                                                      set y to false

                                                      if(x::Length > 1)

                                                          set y to true

                                                      end-if

                                                  end-delegate).

The reference to System.Core is required since Where is actually an extension method defined in that assembly.  Normally it would be better to set this ilref directive, and the ilusing directive using project settings In Visual Studio.


Viewing all articles
Browse latest Browse all 4356

Trending Articles



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