Hi!
In this new version of VC, it's possible to use linq or lambda expressions, like, "myList.ForEach(x => Console.WriteLine(x));" ?
#VisualCOBOL
#Linq
#lambda
Hi!
In this new version of VC, it's possible to use linq or lambda expressions, like, "myList.ForEach(x => Console.WriteLine(x));" ?
Hi!
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)
end-delegate).
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
end-if
end-delegate).
Hi!
In this new version of VC, it's possible to use linq or lambda expressions, like, "myList.ForEach(x => Console.WriteLine(x));" ?
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.
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.