Lambda expression and Linq

In this new version of VC, it's possible to use linq or lambda expressions, like, "myList.ForEach(x => Console.WriteLine(x));" ?

  • About use the "ForEach" of list class, I solved...

               invoke myList::ForEach(delegate using x as type String
                                               invoke type Console::WriteLine(x)

    but, it's possible to use the Linq to objects method ?

    Something like this ??????:
    set minhaNovaLista to minhaLista::Where(delegate using x as type String returning y as type String
                                                           if(x::Length > 1)
                                                               move x to y

  • Verified Answer

    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


              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



    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.